コード例 #1
0
        /// <summary>
        /// Prepares the environment (dataset, predictions, evaluation engine etc) before each test.
        /// </summary>
        public RecommenderEvaluatorTests()
        {
            this.dataset = new[]
            {
                // user, item, predicted rating, prediction distribution, true rating (data domain)
                Tuple.Create <string, string, int, RatingDistribution, double>(
                    "A", "a", 4, new SortedDictionary <int, double> {
                    { 0, 0.0 }, { 1, 0.2 }, { 2, 0.0 }, { 3, 0.0 }, { 4, 0.6 }, { 5, 0.2 }
                }, 1.1),
                Tuple.Create <string, string, int, RatingDistribution, double>(
                    "B", "a", 1, new SortedDictionary <int, double> {
                    { 0, 0.0 }, { 1, 0.5 }, { 2, 0.0 }, { 3, 0.0 }, { 4, 0.5 }, { 5, 0.0 }
                }, 4.1),
                Tuple.Create <string, string, int, RatingDistribution, double>(
                    "D", "b", 2, new SortedDictionary <int, double> {
                    { 0, 0.0 }, { 1, 0.0 }, { 2, 1.0 }, { 3, 0.0 }, { 4, 0.0 }, { 5, 0.0 }
                }, 1.9),
                Tuple.Create <string, string, int, RatingDistribution, double>(
                    "A", "b", 5, new SortedDictionary <int, double> {
                    { 0, 0.0 }, { 1, 0.0 }, { 2, 0.0 }, { 3, 0.0 }, { 4, 0.2 }, { 5, 0.8 }
                }, 5.3),
                Tuple.Create <string, string, int, RatingDistribution, double>(
                    "A", "c", 3, new SortedDictionary <int, double> {
                    { 0, 0.0 }, { 1, 0.0 }, { 2, 0.0 }, { 3, 0.6 }, { 4, 0.2 }, { 5, 0.2 }
                }, 4.7),
                Tuple.Create <string, string, int, RatingDistribution, double>(
                    "A", "e", 1, new SortedDictionary <int, double> {
                    { 0, 0.0 }, { 1, 0.5 }, { 2, 0.0 }, { 3, 0.0 }, { 4, 0.5 }, { 5, 0.0 }
                }, 3.6),
                Tuple.Create <string, string, int, RatingDistribution, double>(
                    "B", "c", 2, new SortedDictionary <int, double> {
                    { 0, 0.0 }, { 1, 0.0 }, { 2, 0.8 }, { 3, 0.2 }, { 4, 0.0 }, { 5, 0.0 }
                }, 3.1)
            };

            var recommenderMapping = new StarRatingRecommenderMapping();
            var evaluatorMapping   = recommenderMapping.ForEvaluation();

            this.starRatingInfo       = recommenderMapping.GetRatingInfo(null);
            this.evaluator            = new StarRatingRecommenderEvaluator <IEnumerable <Instance>, string, string, double>(evaluatorMapping);
            this.predictions          = BuildPredictionDictionary(this.dataset, i => i.Item3);
            this.uncertainPredictions = BuildPredictionDictionary(this.dataset, i => i.Item4);
        }
コード例 #2
0
 /// <summary>
 /// Initializes static members of the <see cref="Mappings"/> class.
 /// </summary>
 static Mappings()
 {
     StarRatingRecommender = new StarRatingRecommenderMapping();
     Classifier            = new ClassifierMapping();
 }