Created
April 30, 2019 09:40
-
-
Save AndyButland/ee5482f9f1f93ff61548f0f8b8361faf to your computer and use it in GitHub Desktop.
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
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