Exemplo n.º 1
0
        static readonly string _modelpath    = Path.Combine(Environment.CurrentDirectory, "Data", "Model.zip");           //Eğitimli modelin depolandığı dosyanın yolu.

        static async Task Main(string[] args)
        {
            Console.WriteLine(Environment.CurrentDirectory);
            PredictionModel <TaxiTrip, TaxiTripFarePrediction> model = await Train();

            TaxiTripFarePrediction prediction = model.Predict(TestTrips.Trip1);

            Console.WriteLine("Predicted fare: {0}, actual fare: 29.5", prediction.FareAmount);
            Evaluate(model);
        }
Exemplo n.º 2
0
        static async Task Main(string[] args)
        {
            /* BEGIN This code produces a model and performs a prediction
             * PredictionModel<TaxiTrip, TaxiTripFarePrediction> model = await Train();
             * Evaluate(model);
             * TaxiTripFarePrediction prediction = model.Predict(getTrip());
             * Console.WriteLine("Predicted fare: {0}, actual fare: 29.5", prediction.FareAmount);
             */

            /* This code performs a prediction from the model file (Model.zip) */
            TaxiTripFarePrediction prediction = await Predict(getTrip());

            Console.WriteLine("Predicted fare: {0}, actual fare: 29.5", prediction.FareAmount);
        }
Exemplo n.º 3
0
        private static void Evaluate(PredictionModel <TaxiTrip, TaxiTripFarePrediction> model)
        {
            var testData = new TextLoader(_testdatapath).CreateFrom <TaxiTrip>(useHeader: true, separator: ',');

            var evaluator             = new RegressionEvaluator();
            RegressionMetrics metrics = evaluator.Evaluate(model, testData);

            Console.WriteLine($"RMS = {metrics.Rms}");
            Console.WriteLine($"RSquared = {metrics.RSquared}");


            // Using the model for predictions
            TaxiTripFarePrediction prediction = model.Predict(TestTrip.Trip1);

            Console.WriteLine($"Predicted fare: {prediction.FareAmount}, actual fare: 29.5");
        }
Exemplo n.º 4
0
        private static void TestSinglePrediction(TaxiFarePredictionEngine.PredictionEngine predictionEngine)
        {
            TaxiTrip taxiTripSample = new TaxiTrip()
            {
                VendorId       = "VTS",
                RateCode       = "1",
                PassengerCount = 1,
                TripTime       = 1140,
                TripDistance   = 3.75f,
                PaymentType    = "CRD",
                FareAmount     = 0
            };

            TaxiTripFarePrediction prediction = predictionEngine.GetFarePrediction(taxiTripSample);

            Console.WriteLine($"**********************************************************************");
            Console.WriteLine($"Predicted fare: {prediction.FareAmount:0.####}, actual fare: 15.5");
            Console.WriteLine($"**********************************************************************");
        }
Exemplo n.º 5
0
        // </Snippet2>

        // <Snippet8>
        static async Task Main(string[] args)
        // </Snippet8>
        {
            Console.WriteLine(Environment.CurrentDirectory);
            // <Snippet7>
            PredictionModel <TaxiTrip, TaxiTripFarePrediction> model = await Train();

            // </Snippet7>

            // <Snippet10>
            Evaluate(model);
            // </Snippet10>

            // <Snippet16>
            TaxiTripFarePrediction prediction = model.Predict(TestTrips.Trip1);

            Console.WriteLine("Predicted fare: {0}, actual fare: 29.5", prediction.FareAmount);
            Console.Read();
            // </Snippet16>
        }
Exemplo n.º 6
0
        static async Task Main(string[] args)
        {
            try
            {
                //Train
                PredictionModel <TaxiTrip, TaxiTripFarePrediction> model = await Train();

                //Eval - Evaluate accuracy of predictions using test data
                Evaluate(model);

                //Predict
                TaxiTripFarePrediction prediction = model.Predict(TestTrips.Trip1);

                Console.WriteLine("Predicted fare: {0}, actual fare: 29.5", prediction.FareAmount);
                Console.ReadKey();
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Exception Message: {ex.Message}");
                Console.ReadKey();
            }
        }