Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var data = CsvReader.ReadData();

            var userId = 186;

            //User-Item
            KNearestNeighbours kNearestNeighbours = new KNearestNeighbours(0.35);
            var nearestNeighbours = kNearestNeighbours.GetNearestNeighbours(data, userId, 25);
            var topRatings        = GetTopXAmountOfRecommendations.GetTopXAmountOfRatings(8, nearestNeighbours, 3);

            //Item-Item
            var top5 = ItemItemLogic.RunItemItemMethods(data, userId);
        }
        private static void RunUserItemMethods(Dictionary <int, Dictionary <int, double> > dictionary)
        {
            var userId = 186;
            var itemId = 514;

            KNearestNeighbours kNearestNeighbours = new KNearestNeighbours();
            var nearestNeigbours = kNearestNeighbours.GetNearestNeighbours(userId, dictionary[userId], dictionary, 25, 0.35);

            foreach (var item in nearestNeigbours)
            {
                Console.WriteLine("Id: {0}  Similarity: {1}", item.Key, item.Similarity);
            }

            //PredictedRatingCalculations predictedRatingCalculations = new PredictedRatingCalculations();
            //var predRating = predictedRatingCalculations.CalculatePredictedRating(itemId, nearestNeigbours, dictionary);
            //Console.WriteLine("Predicted Rating: {0}" , predRating);

            var topRatings = GetTopXAmountOfRatings(8, nearestNeigbours, dictionary);

            foreach (var rating in topRatings)
            {
                Console.WriteLine("Predicted Rating: {0}", rating);
            }
        }