Last active
March 10, 2022 01:37
-
-
Save mdfarragher/ea98c3455b56764002e751341e79f80f to your computer and use it in GitHub Desktop.
This code is part of the ML.NET taxi fare prediction demo.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create a prediction engine for one single prediction | |
var predictionFunction = model.CreatePredictionEngine<TaxiTrip, TaxiTripFarePrediction>(mlContext); | |
// prep a single taxi trip | |
var taxiTripSample = new TaxiTrip() | |
{ | |
VendorId = "VTS", | |
RateCode = "1", | |
PassengerCount = 1, | |
TripDistance = 3.75f, | |
PaymentType = "1", | |
FareAmount = 0 // actual fare for this trip = 15.5 | |
}; | |
// make the prediction | |
var prediction = predictionFunction.Predict(taxiTripSample); | |
// sho the prediction | |
Console.WriteLine($"Single prediction:"); | |
Console.WriteLine($" Predicted fare: {prediction.FareAmount:0.####}"); | |
Console.WriteLine($" Actual fare: 15.5"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment