Class RecommenderEvaluator<TInstanceSource, TUser, TItem, TGroundTruthRating, TPredictedRating, TPredictedRatingDist>
Evaluates a recommender system.
Inheritance
Inherited Members
Namespace: Microsoft.ML.Probabilistic.Learners
Assembly: Microsoft.ML.Probabilistic.Learners.Recommender.dll
Syntax
public class RecommenderEvaluator<TInstanceSource, TUser, TItem, TGroundTruthRating, TPredictedRating, TPredictedRatingDist>
Type Parameters
Name | Description |
---|---|
TInstanceSource | The type of a source of instances. |
TUser | The type of a user. |
TItem | The type of an item. |
TGroundTruthRating | The type of a rating in a test dataset. |
TPredictedRating | The type of a rating predicted by a recommender system. |
TPredictedRatingDist | The type of a distribution over ratings predicted by a recommender system. |
Constructors
RecommenderEvaluator(IRecommenderEvaluatorMapping<TInstanceSource, TUser, TItem, TGroundTruthRating>)
Initializes a new instance of the RecommenderEvaluator<TInstanceSource, TUser, TItem, TGroundTruthRating, TPredictedRating, TPredictedRatingDist> class.
Declaration
public RecommenderEvaluator(IRecommenderEvaluatorMapping<TInstanceSource, TUser, TItem, TGroundTruthRating> mapping)
Parameters
Type | Name | Description |
---|---|---|
IRecommenderEvaluatorMapping<TInstanceSource, TUser, TItem, TGroundTruthRating> | mapping | The mapping used for accessing data. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if the given mapping is null. |
Methods
FindRelatedItemsRatedBySameUsers<TFeatureSource>(IRecommender<TInstanceSource, TUser, TItem, TPredictedRating, TPredictedRatingDist, TFeatureSource>, TInstanceSource, Int32, Int32, Int32, TFeatureSource)
Finds related items for every item in a given instance source.
The subset of items which will be returned as related for a particular item is restricted:
it is guaranteed that all the related items have been rated by at least minCommonRatingCount
users in common with the query item
in the dataset.
Declaration
public IDictionary<TItem, IEnumerable<TItem>> FindRelatedItemsRatedBySameUsers<TFeatureSource>(IRecommender<TInstanceSource, TUser, TItem, TPredictedRating, TPredictedRatingDist, TFeatureSource> recommender, TInstanceSource instanceSource, int maxRelatedItemCount, int minCommonRatingCount, int minRelatedItemPoolSize, TFeatureSource featureSource = null)
Parameters
Type | Name | Description |
---|---|---|
IRecommender<TInstanceSource, TUser, TItem, TPredictedRating, TPredictedRatingDist, TFeatureSource> | recommender | The recommendation engine. |
TInstanceSource | instanceSource | The instance source. |
Int32 | maxRelatedItemCount | Maximum number of related items to return. |
Int32 | minCommonRatingCount | Minimum number of users that the query item and the related item should have been rated by in common. |
Int32 | minRelatedItemPoolSize | If an item has less than |
TFeatureSource | featureSource | The source of features. |
Returns
Type | Description |
---|---|
IDictionary<TItem, IEnumerable<TItem>> | The list of related items for every item in |
Type Parameters
Name | Description |
---|---|
TFeatureSource | The type of a feature source used by the recommendation engine. |
FindRelatedUsersWhoRatedSameItems<TFeatureSource>(IRecommender<TInstanceSource, TUser, TItem, TPredictedRating, TPredictedRatingDist, TFeatureSource>, TInstanceSource, Int32, Int32, Int32, TFeatureSource)
Finds related users for every user in a instance source.
The subset of users who will be returned as related for a particular user is restricted:
it is guaranteed that all the related users have rated at least minCommonRatingCount
items in common with the query user
in the dataset.
Declaration
public IDictionary<TUser, IEnumerable<TUser>> FindRelatedUsersWhoRatedSameItems<TFeatureSource>(IRecommender<TInstanceSource, TUser, TItem, TPredictedRating, TPredictedRatingDist, TFeatureSource> recommender, TInstanceSource instanceSource, int maxRelatedUserCount, int minCommonRatingCount, int minRelatedUserPoolSize, TFeatureSource featureSource = null)
Parameters
Type | Name | Description |
---|---|---|
IRecommender<TInstanceSource, TUser, TItem, TPredictedRating, TPredictedRatingDist, TFeatureSource> | recommender | The recommendation engine. |
TInstanceSource | instanceSource | The instance source. |
Int32 | maxRelatedUserCount | Maximum number of related users to return. |
Int32 | minCommonRatingCount | Minimum number of items that the query user and the related user should have rated in common. |
Int32 | minRelatedUserPoolSize | If a user has less than |
TFeatureSource | featureSource | The source of features. |
Returns
Type | Description |
---|---|
IDictionary<TUser, IEnumerable<TUser>> | The list of related users for every user in |
Type Parameters
Name | Description |
---|---|
TFeatureSource | The type of a feature source used by the recommendation engine. |
ItemRecommendationMetric(TInstanceSource, IDictionary<TUser, IEnumerable<TItem>>, Func<IEnumerable<Double>, IEnumerable<Double>, Double>, Func<TGroundTruthRating, Double>)
Computes the average across users of a given ranking metric for recommendation. Uses ratings to compute gains.
Declaration
public double ItemRecommendationMetric(TInstanceSource instanceSource, IDictionary<TUser, IEnumerable<TItem>> predictions, Func<IEnumerable<double>, IEnumerable<double>, double> metric, Func<TGroundTruthRating, double> ratingConverter = null)
Parameters
Type | Name | Description |
---|---|---|
TInstanceSource | instanceSource | The source of the instances providing the ground truth. |
IDictionary<TUser, IEnumerable<TItem>> | predictions | A mapping from a user to a list of recommended items. |
Func<IEnumerable<Double>, IEnumerable<Double>, Double> | metric | The ranking metric. |
Func<TGroundTruthRating, Double> | ratingConverter | The function used to convert ratings to gains. ToDouble(Object) is used by default. |
Returns
Type | Description |
---|---|
Double | The computed average of the given ranking metric for recommendation. |
ItemRecommendationMetric(TInstanceSource, IDictionary<TUser, IEnumerable<TItem>>, Func<IEnumerable<Double>, Double>, Func<TGroundTruthRating, Double>)
Computes the average across users of a given ranking metric for recommendation. Uses ratings to compute gains.
Declaration
public double ItemRecommendationMetric(TInstanceSource instanceSource, IDictionary<TUser, IEnumerable<TItem>> predictions, Func<IEnumerable<double>, double> metric, Func<TGroundTruthRating, double> ratingConverter = null)
Parameters
Type | Name | Description |
---|---|---|
TInstanceSource | instanceSource | The source of the instances providing the ground truth. |
IDictionary<TUser, IEnumerable<TItem>> | predictions | A mapping from a user to a list of recommended items. |
Func<IEnumerable<Double>, Double> | metric | The ranking metric. |
Func<TGroundTruthRating, Double> | ratingConverter | The function used to convert ratings to gains. ToDouble(Object) is used by default. |
Returns
Type | Description |
---|---|
Double | The computed average of the given ranking metric for recommendation. |
RatingPredictionMetric(TInstanceSource, IDictionary<TUser, IDictionary<TItem, TPredictedRating>>, Func<TGroundTruthRating, TPredictedRating, Double>, RecommenderMetricAggregationMethod)
Computes the average of a given data domain rating prediction metric by iterating firstly per-item and then per-user.
Declaration
public double RatingPredictionMetric(TInstanceSource instanceSource, IDictionary<TUser, IDictionary<TItem, TPredictedRating>> predictions, Func<TGroundTruthRating, TPredictedRating, double> metric, RecommenderMetricAggregationMethod aggregationMethod = RecommenderMetricAggregationMethod.Default)
Parameters
Type | Name | Description |
---|---|---|
TInstanceSource | instanceSource | The source of the instances providing the ground truth. |
IDictionary<TUser, IDictionary<TItem, TPredictedRating>> | predictions | A sparse users-by-items matrix of predicted rating distributions. |
Func<TGroundTruthRating, TPredictedRating, Double> | metric | The data domain rating prediction metric to average. |
RecommenderMetricAggregationMethod | aggregationMethod | A method specifying how metrics are aggregated over the whole dataset. |
Returns
Type | Description |
---|---|
Double | The computed average of the given rating prediction metric. |
RatingPredictionMetric(TInstanceSource, IDictionary<TUser, IDictionary<TItem, TPredictedRatingDist>>, Func<TGroundTruthRating, TPredictedRatingDist, Double>, RecommenderMetricAggregationMethod)
Computes the average of a given data domain rating prediction metric by iterating firstly per-item and then per-user.
Declaration
public double RatingPredictionMetric(TInstanceSource instanceSource, IDictionary<TUser, IDictionary<TItem, TPredictedRatingDist>> predictions, Func<TGroundTruthRating, TPredictedRatingDist, double> metric, RecommenderMetricAggregationMethod aggregationMethod = RecommenderMetricAggregationMethod.Default)
Parameters
Type | Name | Description |
---|---|---|
TInstanceSource | instanceSource | The source of the instances providing the ground truth. |
IDictionary<TUser, IDictionary<TItem, TPredictedRatingDist>> | predictions | A sparse users-by-items matrix of predicted rating distributions. |
Func<TGroundTruthRating, TPredictedRatingDist, Double> | metric | The data domain rating prediction metric to average. |
RecommenderMetricAggregationMethod | aggregationMethod | A method specifying how metrics are aggregated over the whole dataset. |
Returns
Type | Description |
---|---|
Double | The computed average of the given rating prediction metric. |
RecommendRatedItems<TFeatureSource>(IRecommender<TInstanceSource, TUser, TItem, TPredictedRating, TPredictedRatingDist, TFeatureSource>, TInstanceSource, Int32, Int32, TFeatureSource)
For each user in a given instance source recommends items from the set of items rated by the user.
Declaration
public IDictionary<TUser, IEnumerable<TItem>> RecommendRatedItems<TFeatureSource>(IRecommender<TInstanceSource, TUser, TItem, TPredictedRating, TPredictedRatingDist, TFeatureSource> recommender, TInstanceSource instanceSource, int maxRecommendedItemCount, int minRecommendationPoolSize, TFeatureSource featureSource = null)
Parameters
Type | Name | Description |
---|---|---|
IRecommender<TInstanceSource, TUser, TItem, TPredictedRating, TPredictedRatingDist, TFeatureSource> | recommender | The recommendation engine. |
TInstanceSource | instanceSource | The instance source. |
Int32 | maxRecommendedItemCount | Maximum number of items to recommend to a user. |
Int32 | minRecommendationPoolSize | If a user has less than |
TFeatureSource | featureSource | The source of features. |
Returns
Type | Description |
---|---|
IDictionary<TUser, IEnumerable<TItem>> | The list of recommended items for every user in |
Type Parameters
Name | Description |
---|---|
TFeatureSource | The type of a feature source used by the recommendation engine. |
RelatedItemsMetric(TInstanceSource, IDictionary<TItem, IEnumerable<TItem>>, Int32, Func<IEnumerable<Double>, IEnumerable<Double>, Double>, Func<Vector, Vector, Double>, Func<TGroundTruthRating, Double>)
Computes the average of a given ranking metric over a set of ordered sequences of items. Gain for ranking is defined as the rating similarity between the items in the list and the query item.
Declaration
public double RelatedItemsMetric(TInstanceSource instanceSource, IDictionary<TItem, IEnumerable<TItem>> predictions, int minCommonRatingCount, Func<IEnumerable<double>, IEnumerable<double>, double> rankingMetric, Func<Vector, Vector, double> ratingSimilarityFunc, Func<TGroundTruthRating, double> ratingConverter = null)
Parameters
Type | Name | Description |
---|---|---|
TInstanceSource | instanceSource | The source of the instances providing the ground truth. |
IDictionary<TItem, IEnumerable<TItem>> | predictions | A mapping from an item to a list of predicted related items. |
Int32 | minCommonRatingCount | The minimum number of common ratings two items must have in order to be considered for evaluation. |
Func<IEnumerable<Double>, IEnumerable<Double>, Double> | rankingMetric | The ranking metric. |
Func<Vector, Vector, Double> | ratingSimilarityFunc | A method which computes the similarity between two rating vectors. |
Func<TGroundTruthRating, Double> | ratingConverter | The function applied to ratings before computing similarity. ToDouble(Object) is used by default. |
Returns
Type | Description |
---|---|
Double | The computed average of the given ranking metric. |
RelatedItemsMetric(TInstanceSource, IDictionary<TItem, IEnumerable<TItem>>, Int32, Func<IEnumerable<Double>, Double>, Func<Vector, Vector, Double>, Func<TGroundTruthRating, Double>)
Computes the average of a given ranking metric over a set of ordered sequences of items. Gain for ranking is defined as the rating similarity between the items in the list and the query item.
Declaration
public double RelatedItemsMetric(TInstanceSource instanceSource, IDictionary<TItem, IEnumerable<TItem>> predictions, int minCommonRatingCount, Func<IEnumerable<double>, double> rankingMetric, Func<Vector, Vector, double> ratingSimilarityFunc, Func<TGroundTruthRating, double> ratingConverter = null)
Parameters
Type | Name | Description |
---|---|---|
TInstanceSource | instanceSource | The source of the instances providing the ground truth. |
IDictionary<TItem, IEnumerable<TItem>> | predictions | A mapping from an item to a list of predicted related items. |
Int32 | minCommonRatingCount | The minimum number of common ratings two items must have in order to be considered for evaluation. |
Func<IEnumerable<Double>, Double> | rankingMetric | The ranking metric. |
Func<Vector, Vector, Double> | ratingSimilarityFunc | A method which computes the similarity between two rating vectors. |
Func<TGroundTruthRating, Double> | ratingConverter | The function applied to ratings before computing similarity. ToDouble(Object) is used by default. |
Returns
Type | Description |
---|---|
Double | The computed average of the given ranking metric. |
RelatedUsersMetric(TInstanceSource, IDictionary<TUser, IEnumerable<TUser>>, Int32, Func<IEnumerable<Double>, IEnumerable<Double>, Double>, Func<Vector, Vector, Double>, Func<TGroundTruthRating, Double>)
Computes the average of a given ranking metric over a set of ordered sequences of users. Gain for ranking is defined as the rating similarity between the users in the list and the query user.
Declaration
public double RelatedUsersMetric(TInstanceSource instanceSource, IDictionary<TUser, IEnumerable<TUser>> predictions, int minCommonRatingCount, Func<IEnumerable<double>, IEnumerable<double>, double> rankingMetric, Func<Vector, Vector, double> ratingSimilarityFunc, Func<TGroundTruthRating, double> ratingConverter = null)
Parameters
Type | Name | Description |
---|---|---|
TInstanceSource | instanceSource | The source of the instances providing the ground truth. |
IDictionary<TUser, IEnumerable<TUser>> | predictions | A mapping from a user to a list of predicted related users. |
Int32 | minCommonRatingCount | The minimum number of common ratings two users must have in order to be considered for evaluation. |
Func<IEnumerable<Double>, IEnumerable<Double>, Double> | rankingMetric | The ranking metric. |
Func<Vector, Vector, Double> | ratingSimilarityFunc | A method which computes the similarity between two rating vectors. |
Func<TGroundTruthRating, Double> | ratingConverter | The function applied to ratings before computing similarity. ToDouble(Object) is used by default. |
Returns
Type | Description |
---|---|
Double | The computed average of the given ranking metric. |
RelatedUsersMetric(TInstanceSource, IDictionary<TUser, IEnumerable<TUser>>, Int32, Func<IEnumerable<Double>, Double>, Func<Vector, Vector, Double>, Func<TGroundTruthRating, Double>)
Computes the average of a given ranking metric over a set of ordered sequences of users. Gain for ranking is defined as the rating similarity between the users in the list and the query user.
Declaration
public double RelatedUsersMetric(TInstanceSource instanceSource, IDictionary<TUser, IEnumerable<TUser>> predictions, int minCommonRatingCount, Func<IEnumerable<double>, double> rankingMetric, Func<Vector, Vector, double> ratingSimilarityFunc, Func<TGroundTruthRating, double> ratingConverter = null)
Parameters
Type | Name | Description |
---|---|---|
TInstanceSource | instanceSource | The source of the instances providing the ground truth. |
IDictionary<TUser, IEnumerable<TUser>> | predictions | A mapping from a user to a list of predicted related users. |
Int32 | minCommonRatingCount | The minimum number of common ratings two users must have in order to be considered for evaluation. |
Func<IEnumerable<Double>, Double> | rankingMetric | The ranking metric. |
Func<Vector, Vector, Double> | ratingSimilarityFunc | A method which computes the similarity between two rating vectors. |
Func<TGroundTruthRating, Double> | ratingConverter | The function applied to ratings before computing similarity. ToDouble(Object) is used by default. |
Returns
Type | Description |
---|---|
Double | The computed average of the given ranking metric. |