private static void singlePredictionDiagnostic(Dictionary <int, User> allUsers) { var userSeven = allUsers[7]; ISimilarity similarityMeasure = new PearsonSimilarity(); var userSevenNeighboursAndSimilarities = userSeven.getNearestNeighboursAndSimilarities(3, allUsers.Values.ToList(), similarityMeasure); Console.WriteLine(""); IRatingPrediction weightedAvgPrediction = new WeightedAveragePrediction(); Console.WriteLine("User no. 7 predicted rating of product no. 101 using pearson is " + weightedAvgPrediction.predictRating(101, userSevenNeighboursAndSimilarities)); Console.WriteLine("User no. 7 predicted rating of product no. 103 using pearson is " + weightedAvgPrediction.predictRating(103, userSevenNeighboursAndSimilarities)); Console.WriteLine("User no. 7 predicted rating of product no. 106 using pearson is " + weightedAvgPrediction.predictRating(106, userSevenNeighboursAndSimilarities)); //INCORRECT, CHECK THIS ONE var userFour = allUsers[4]; var userFourNeighboursAndSimilarities = userFour.getNearestNeighboursAndSimilarities(3, allUsers.Values.ToList(), similarityMeasure); Console.WriteLine(""); Console.WriteLine("User no. 4 predicted rating of product no. 101 using pearson is " + weightedAvgPrediction.predictRating(101, userFourNeighboursAndSimilarities)); Console.WriteLine(""); Console.WriteLine("USER NO. 7 RATED ITEM 106 AS A 2.8: REDOING PREDICTIONS OF ITEMS 101 and 103"); userSeven.ratings[106] = 2.8; userSevenNeighboursAndSimilarities = userSeven.getNearestNeighboursAndSimilarities(3, allUsers.Values.ToList(), similarityMeasure); Console.WriteLine("User no. 7 predicted rating of product no. 101, with rating of product no. 106 set to 2.8 using pearson is " + weightedAvgPrediction.predictRating(101, userSevenNeighboursAndSimilarities)); Console.WriteLine("User no. 7 predicted rating of product no. 103, with rating of product no. 106 set to 2.8 using pearson is " + weightedAvgPrediction.predictRating(103, userSevenNeighboursAndSimilarities)); Console.WriteLine(""); Console.WriteLine("USER NO. 7 NOW RATED ITEM 106 AS A 5: REDOING PREDICTIONS OF ITEMS 101 and 103"); userSeven.ratings[106] = 5; userSevenNeighboursAndSimilarities = userSeven.getNearestNeighboursAndSimilarities(3, allUsers.Values.ToList(), similarityMeasure); Console.WriteLine("User no. 7 predicted rating of product no. 101, with rating of product no. 106 updated to 5 using pearson is " + weightedAvgPrediction.predictRating(101, userSevenNeighboursAndSimilarities)); Console.WriteLine("User no. 7 predicted rating of product no. 103, with rating of product no. 106 updated to 5 using pearson is " + weightedAvgPrediction.predictRating(103, userSevenNeighboursAndSimilarities)); }
private static void nDimensionalRecommendationDiagnostic(Dictionary <int, User> sortedUserItems) { var user186 = sortedUserItems[186]; ISimilarity pearsonSimilarity = new PearsonSimilarity(); IRatingPrediction weightedAvgPrediction = new WeightedAveragePrediction(); int neighboursAmount = 25; RecommendationCreator recommendationCreator = new RecommendationCreator(pearsonSimilarity, weightedAvgPrediction, neighboursAmount); int recommendationAmount = 8; int minimumAmountOfNeighbourProductOccurences = 0; var top8Recommendations = recommendationCreator.getListOfTopPredictedRatings(recommendationAmount, minimumAmountOfNeighbourProductOccurences, sortedUserItems, user186); Console.WriteLine(""); Console.WriteLine("Top 8 recommendations for user 186 with " + neighboursAmount + " neighbours and minimumAmountOfNeighbourProductOccurences = 0: "); Console.WriteLine("-------------------------------------"); Console.WriteLine(""); int counter = 0; top8Recommendations.ForEach(x => Console.WriteLine("Top " + (++counter) + " product: Movie no. " + x.Key + ", predicted rating " + x.Value)); Console.WriteLine(""); recommendationAmount = 8; minimumAmountOfNeighbourProductOccurences = 3; top8Recommendations = recommendationCreator.getListOfTopPredictedRatings(recommendationAmount, minimumAmountOfNeighbourProductOccurences, sortedUserItems, user186); Console.WriteLine(""); Console.WriteLine("Top 8 recommendations for user 186 with " + neighboursAmount + " neighbours and minimumAmountOfNeighbourProductOccurences = 3: "); Console.WriteLine("-------------------------------------"); Console.WriteLine(""); counter = 0; top8Recommendations.ForEach(x => Console.WriteLine("Top " + (++counter) + " product: Movie no. " + x.Key + ", predicted rating " + x.Value)); }