private void PrintRatingPredictionResults(MalRecResults<IEnumerable<IRecommendation>> basicResults, IDictionary<int, MalListEntry> animeList, decimal targetScore)
 {
     MalRecResults<IEnumerable<RatingPredictionRecommendation>> results = basicResults.CastRecs<IEnumerable<RatingPredictionRecommendation>>();
     int recNumber = 1;
     foreach (var recIt in results.Results.AsSmartEnumerable())
     {
         RatingPredictionRecommendation rec = recIt.Value;
         if (recIt.IsFirst)
         {
             Console.WriteLine("     {0,-60} {1}", "Anime", "Prediction");
         }
         Console.WriteLine("{0,3}. {1,-60} {2:F3}", recNumber, results.AnimeInfo[rec.ItemId].Title, rec.PredictedRating);
         recNumber++;
     }
 }
        private void PrintRatingPredictionResults(MalRecResults <IEnumerable <IRecommendation> > basicResults, IDictionary <int, MalListEntry> animeList, decimal targetScore)
        {
            MalRecResults <IEnumerable <RatingPredictionRecommendation> > results = basicResults.CastRecs <IEnumerable <RatingPredictionRecommendation> >();
            int recNumber = 1;

            foreach (RatingPredictionRecommendation rec in results.Results)
            {
                if (recNumber == 1)
                {
                    Console.WriteLine("     {0,-60} {1}", "Anime", "Prediction");
                }
                Console.WriteLine("{0,3}. {1,-60} {2:F3}", recNumber, results.AnimeInfo[rec.ItemId].Title, rec.PredictedRating);
                recNumber++;
            }
        }
Ejemplo n.º 3
0
        private void PrintAverageScoreResults(MalRecResults <IEnumerable <IRecommendation> > basicResults, IDictionary <int, MalListEntry> animeList, decimal targetScore)
        {
            MalRecResults <IEnumerable <AverageScoreRecommendation> > results = basicResults.CastRecs <IEnumerable <AverageScoreRecommendation> >();
            int recNumber = 1;

            foreach (AverageScoreRecommendation rec in results.Results)
            {
                if (recNumber == 1)
                {
                    Console.WriteLine("     {0,-52} {1,-6} {2}", "Anime", "Avg", "# ratings");
                }

                Console.WriteLine("{0,3}. {1,-52} {2,-6:f2} {3}", recNumber, results.AnimeInfo[rec.ItemId].Title, rec.AverageScore, rec.NumRatings);
                recNumber++;
            }
        }
        private void PrintMostPopularResults(MalRecResults<IEnumerable<IRecommendation>> basicResults, IDictionary<int, MalListEntry> animeList, decimal targetScore)
        {
            MalRecResults<IEnumerable<MostPopularRecommendation>> results = basicResults.CastRecs<IEnumerable<MostPopularRecommendation>>();
            int recNumber = 1;
            foreach (var recIt in results.Results.AsSmartEnumerable())
            {
                MostPopularRecommendation rec = recIt.Value;
                if (recIt.IsFirst)
                {
                    Console.WriteLine("     {0,-52} {1,4} {2}", "Anime", "Rank", "# ratings");
                }

                Console.WriteLine("{0,3}. {1,-52} {2,4} {3}", recNumber, results.AnimeInfo[rec.ItemId].Title, rec.PopularityRank, rec.NumRatings);
                recNumber++;
            }
        }
        private void PrintAnimeRecsResults(MalRecResults<IEnumerable<IRecommendation>> basicResults, IDictionary<int, MalListEntry> animeList, decimal targetScore)
        {
            MalRecResults<MalAnimeRecsResults> results = basicResults.CastRecs<MalAnimeRecsResults>();

            int numRecommendersPrinted = 0;

            foreach (MalAnimeRecsRecommenderUser recommender in results.Results.Recommenders)
            {
                if (numRecommendersPrinted > 10)
                {
                    break;
                }

                string recsLikedString;

                if (recommender.NumRecsWithJudgment > 0)
                {
                    recsLikedString = string.Format("{0:P2}", (double)recommender.RecsLiked.Count / recommender.NumRecsWithJudgment);
                }
                else
                {
                    recsLikedString = string.Format("{0:P2}", 0);
                }

                Console.WriteLine("{0}'s recommendations ({1}/{2} {3} recs liked, {4:P2} - {5:P2} estimated compatibility",
                    recommender.Username, recommender.RecsLiked.Count, recommender.NumRecsWithJudgment, recsLikedString,
                    recommender.CompatibilityLowEndpoint ?? 0, recommender.CompatibilityHighEndpoint ?? 0);

                Console.WriteLine("{0,-52} {1,-5} {2,-4} {3,-5} {4,-4} {5}", "Anime", "State", "Like", "Their", "Your", "Avg");

                foreach (MalAnimeRecsRecommenderRecommendation recommendation in recommender.AllRecommendations.OrderBy(
                    rec => !recommender.RecsLiked.Contains(rec) && !recommender.RecsNotLiked.Contains(rec) ? 0 :
                        recommender.RecsLiked.Contains(rec) ? 1 :
                        2
                    )
                    .ThenByDescending(rec => rec.RecommenderScore)
                    .ThenByDescending(rec => rec.AverageScore))
                {
                    string status;
                    decimal? yourRating = null;
                    if (!animeList.ContainsKey(recommendation.MalAnimeId))
                    {
                        status = "-"; // not watched, not in list
                    }
                    else
                    {
                        if (animeList[recommendation.MalAnimeId].Status == CompletionStatus.Completed)
                            status = "comp";
                        else if (animeList[recommendation.MalAnimeId].Status == CompletionStatus.Dropped)
                            status = "drop";
                        else if (animeList[recommendation.MalAnimeId].Status == CompletionStatus.OnHold)
                            status = "hold";
                        else if (animeList[recommendation.MalAnimeId].Status == CompletionStatus.PlanToWatch)
                            status = "plan";
                        else if (animeList[recommendation.MalAnimeId].Status == CompletionStatus.Watching)
                            status = "watch";
                        else
                            status = "?";

                        yourRating = animeList[recommendation.MalAnimeId].Rating;
                    }

                    string yourRatingString;
                    if (yourRating != null)
                    {
                        yourRatingString = yourRating.Value.ToString(CultureInfo.CurrentCulture);
                    }
                    else
                    {
                        yourRatingString = "-";
                    }

                    string likedString;
                    if (recommender.RecsLiked.Contains(recommendation))
                        likedString = "+";
                    else if (recommender.RecsNotLiked.Contains(recommendation))
                        likedString = "-";
                    else
                        likedString = "?";

                    Console.WriteLine("{0,-52} {1,-5} {2,-4} {3,-5:F0} {4,-4:F0} {5:F2}",
                        results.AnimeInfo[recommendation.MalAnimeId].Title, status, likedString, recommendation.RecommenderScore,
                        yourRatingString, recommendation.AverageScore);
                }

                Console.WriteLine();
                Console.WriteLine();

                numRecommendersPrinted++;
            }
        }
        private void PrintAnimeRecsResults(MalRecResults <IEnumerable <IRecommendation> > basicResults, IDictionary <int, MalListEntry> animeList, decimal targetScore)
        {
            MalRecResults <MalAnimeRecsResults> results = basicResults.CastRecs <MalAnimeRecsResults>();

            int numRecommendersPrinted = 0;

            foreach (MalAnimeRecsRecommenderUser recommender in results.Results.Recommenders)
            {
                if (numRecommendersPrinted > 10)
                {
                    break;
                }

                string recsLikedString;

                if (recommender.NumRecsWithJudgment > 0)
                {
                    recsLikedString = string.Format("{0:P2}", (double)recommender.RecsLiked.Count / recommender.NumRecsWithJudgment);
                }
                else
                {
                    recsLikedString = string.Format("{0:P2}", 0);
                }

                Console.WriteLine("{0}'s recommendations ({1}/{2} {3} recs liked, {4:P2} - {5:P2} estimated compatibility",
                                  recommender.Username, recommender.RecsLiked.Count, recommender.NumRecsWithJudgment, recsLikedString,
                                  recommender.CompatibilityLowEndpoint ?? 0, recommender.CompatibilityHighEndpoint ?? 0);

                Console.WriteLine("{0,-52} {1,-5} {2,-4} {3,-5} {4,-4} {5}", "Anime", "State", "Like", "Their", "Your", "Avg");

                foreach (MalAnimeRecsRecommenderRecommendation recommendation in recommender.AllRecommendations.OrderBy(
                             rec => !recommender.RecsLiked.Contains(rec) && !recommender.RecsNotLiked.Contains(rec) ? 0 :
                             recommender.RecsLiked.Contains(rec) ? 1 :
                             2
                             )
                         .ThenByDescending(rec => rec.RecommenderScore)
                         .ThenByDescending(rec => rec.AverageScore))
                {
                    string  status;
                    decimal?yourRating = null;
                    if (!animeList.ContainsKey(recommendation.MalAnimeId))
                    {
                        status = "-"; // not watched, not in list
                    }
                    else
                    {
                        if (animeList[recommendation.MalAnimeId].Status == CompletionStatus.Completed)
                        {
                            status = "comp";
                        }
                        else if (animeList[recommendation.MalAnimeId].Status == CompletionStatus.Dropped)
                        {
                            status = "drop";
                        }
                        else if (animeList[recommendation.MalAnimeId].Status == CompletionStatus.OnHold)
                        {
                            status = "hold";
                        }
                        else if (animeList[recommendation.MalAnimeId].Status == CompletionStatus.PlanToWatch)
                        {
                            status = "plan";
                        }
                        else if (animeList[recommendation.MalAnimeId].Status == CompletionStatus.Watching)
                        {
                            status = "watch";
                        }
                        else
                        {
                            status = "?";
                        }

                        yourRating = animeList[recommendation.MalAnimeId].Rating;
                    }

                    string yourRatingString;
                    if (yourRating != null)
                    {
                        yourRatingString = yourRating.Value.ToString(CultureInfo.CurrentCulture);
                    }
                    else
                    {
                        yourRatingString = "-";
                    }

                    string likedString;
                    if (recommender.RecsLiked.Contains(recommendation))
                    {
                        likedString = "+";
                    }
                    else if (recommender.RecsNotLiked.Contains(recommendation))
                    {
                        likedString = "-";
                    }
                    else
                    {
                        likedString = "?";
                    }

                    Console.WriteLine("{0,-52} {1,-5} {2,-4} {3,-5:F0} {4,-4:F0} {5:F2}",
                                      results.AnimeInfo[recommendation.MalAnimeId].Title, status, likedString, recommendation.RecommenderScore,
                                      yourRatingString, recommendation.AverageScore);
                }

                Console.WriteLine();
                Console.WriteLine();

                numRecommendersPrinted++;
            }
        }