Skip to content

Instantly share code, notes, and snippets.

@AndyButland
Created April 30, 2019 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndyButland/ee5482f9f1f93ff61548f0f8b8361faf to your computer and use it in GitHub Desktop.
Save AndyButland/ee5482f9f1f93ff61548f0f8b8361faf to your computer and use it in GitHub Desktop.
private static void TestSinglePrediction(MLContext context)
{
// For this test we'll load the model back from disk.
using (var stream = new FileStream(ModelPath, FileMode.Open, FileAccess.Read, FileShare.Read))
{
var loadedModel = context.Model.Load(stream);
var predictionFunction = loadedModel.CreatePredictionEngine<CountryData, CountryHappinessScorePrediction>(context);
// Record of Italy - expected 5.964
var sample = new CountryData
{
Population = 58133509,
Area = 301230,
PopulationDensity = 193,
Coastline = 2.52f,
NetMigration = 2.07f,
InfantMortality = 5.94f,
GDP = 26700,
Literacy = 98.6f,
Phones = 430.9f,
Arable = 27.79f,
Climate = 0,
Birthrate = 8.72f,
Deathrate = 10.4f
};
var prediction = predictionFunction.Predict(sample);
OutputSinglePredictionResult(prediction);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment