Created
December 3, 2019 14:57
-
-
Save icebeam7/d2cd46c7ab08588eac6205a110bfa923 to your computer and use it in GitHub Desktop.
MovieRecommender: UseModelForSinglePrediction
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
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