Skip to content

Instantly share code, notes, and snippets.

@icebeam7
Created December 3, 2019 14:57
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 icebeam7/d2cd46c7ab08588eac6205a110bfa923 to your computer and use it in GitHub Desktop.
Save icebeam7/d2cd46c7ab08588eac6205a110bfa923 to your computer and use it in GitHub Desktop.
MovieRecommender: UseModelForSinglePrediction
public static void UseModelForSinglePrediction(MLContext mlContext, ITransformer model)
{
Console.WriteLine("=============== Making a prediction ===============");
var predictionEngine = mlContext.Model.CreatePredictionEngine<MovieRating, MovieRatingPrediction>(model);
var testInput = new MovieRating { userId = 6, movieId = 10 };
var movieRatingPrediction = predictionEngine.Predict(testInput);
if (Math.Round(movieRatingPrediction.Score, 1) > 3.5)
Console.WriteLine("Movie " + testInput.movieId + " is recommended for user " + testInput.userId);
else
Console.WriteLine("Movie " + testInput.movieId + " is not recommended for user " + testInput.userId);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment