예제 #1
0
        private double ComputeRMSE(PredictionMethod m, RecommenderSystemEngine engineTrain, IEnumerable <RankingDB.RankData> allTest)
        {
            double sum = 0;

            foreach (var rankData in allTest)
            {
                double pretictedRating = Math.Round(engineTrain.PredictRating(m, rankData.ranker, rankData.item));
                sum += Math.Pow((rankData.rank - pretictedRating), 2);
            }
            return(Math.Sqrt(sum / allTest.Count()));
        }
예제 #2
0
        //return an histogram of all ratings that the user has used

        /*public Dictionary<double, int> GetRatingsHistogram(string sUID)
         * {
         *  Dictionary<double, int> res = new Dictionary<double, int>();
         *
         *  IEnumerable<double> AllRanks = _ratings.GetRanks(sUID);
         *  foreach (var rank in AllRanks)
         *  {
         *      if (!res.ContainsKey(rank))
         *          res[rank] = 0;
         ++res[rank];
         *  }
         *  return res;
         * }*/

        //predict the rating that a user will give to an item using one of the methods "Pearson", "Cosine", "Random"
        public double PredictRating(PredictionMethod m, string sUID, string sIID)
        {
            return(_trainEngine.PredictRating(m, sUID, sIID));
        }