Skip to content

Instantly share code, notes, and snippets.

@Belgian-Coder
Last active January 12, 2019 22:48
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 Belgian-Coder/15b12841c056f23074d91fabf2d81f3a to your computer and use it in GitHub Desktop.
Save Belgian-Coder/15b12841c056f23074d91fabf2d81f3a to your computer and use it in GitHub Desktop.
Ordina-ML.Net_Recommender_System
var predictionFunction = model.CreatePredictionEngine<BookRating, BookRatingPrediction>(mlContext);
var bookPrediction = predictionFunction.Predict(new BookRating
{
user = 91,
bookid = 10365
});
Console.WriteLine($"Predicted rating: {Math.Round(bookPrediction.Score, 1)}");
Console.ReadLine();
Console.WriteLine("Saving model");
using (var stream = new FileStream(
Path.Combine(Environment.CurrentDirectory, Filenames.TrainedModel),
FileMode.Create,
FileAccess.Write,
FileShare.Write))
{
mlContext.Model.Save(model, stream);
Console.WriteLine($"The model is saved as {Filenames.TrainedModel}");
}
Console.ReadLine();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment