static void Main(string[] args) { string errorMessage = ""; if (!File.Exists(MovieTitlesPath)) { errorMessage += $"Failed to find file ${MovieTitlesPath} - please update variable ${nameof(MovieTitlesPath)} or create that file.\n"; } if (!File.Exists(UserRatingsTrainingPath)) { errorMessage += $"Failed to find file ${UserRatingsTrainingPath} - please update variable ${nameof(UserRatingsTrainingPath)} or create that file.\n"; } if (!File.Exists(UserRatingsTestPath)) { errorMessage += $"Failed to find file ${UserRatingsTestPath} - please update variable ${nameof(UserRatingsTestPath)} or create that file.\n"; } if (errorMessage != "") { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Not all files available - not running!"); Console.WriteLine(errorMessage); Console.ResetColor(); Console.WriteLine("Press any key to continue..."); Console.ReadKey(); return; } var startTime = DateTime.Now; Console.WriteLine(startTime); Console.WriteLine("Parsing the input files..."); Dictionary <int, string> movieTitles = CsvParserUtils.ParseCsvAsList <Movie>(MovieTitlesPath).ToDictionary(n => n.MovieId, n => n.Title); UserCache trainingSetCache = UserCache.BuildUserCache(UserRatingsTrainingPath); UserCache testingSetCache = UserCache.BuildUserCache(UserRatingsTestPath); Console.WriteLine("Initializing predictors..."); PearsonCoefficientCalculator pearsonCalculator = new PearsonCoefficientCalculator(trainingSetCache); MovieScorePredictor predictor = new MovieScorePredictor(pearsonCalculator); // NOTE: feel free to comment out any of the lines below depending on what you want to execute MakePredictionsOnTestFileAndCalculateError(predictor, testingSetCache); MakeMovieRecommendationsForUser999999InTrainingSet(predictor, trainingSetCache, movieTitles); var endTime = DateTime.Now; Console.WriteLine(endTime); var totalMinutes = (endTime - startTime).TotalMinutes; Console.WriteLine("Took {0} minutes.", totalMinutes); Console.WriteLine("Press any key to quit..."); Console.ReadKey(); }
public MovieScorePredictor(PearsonCoefficientCalculator pearsonCalculator) { _pearsonCalculator = pearsonCalculator; }