Skip to content

Instantly share code, notes, and snippets.

@icebeam7
Created Dec 3, 2019
Embed
What would you like to do?
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