Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save indraone01/fe920661e74118a45b934885e68d6365 to your computer and use it in GitHub Desktop.
Save indraone01/fe920661e74118a45b934885e68d6365 to your computer and use it in GitHub Desktop.
This code is part of the ML.NET taxi fare prediction demo.
// 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