Class StarRatingRecommenderEvaluator<TInstanceSource, TUser, TItem, TGroundTruthRating>
Evaluates a recommender system which predicts star ratings.
Inheritance
Inherited Members
Namespace: Microsoft.ML.Probabilistic.Learners
Assembly: Microsoft.ML.Probabilistic.Learners.Recommender.dll
Syntax
public class StarRatingRecommenderEvaluator<TInstanceSource, TUser, TItem, TGroundTruthRating> : RecommenderEvaluator<TInstanceSource, TUser, TItem, TGroundTruthRating, int, IDictionary<int, double>>
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. |
Constructors
StarRatingRecommenderEvaluator(IStarRatingRecommenderEvaluatorMapping<TInstanceSource, TUser, TItem, TGroundTruthRating>)
Initializes a new instance of the StarRatingRecommenderEvaluator<TInstanceSource, TUser, TItem, TGroundTruthRating> class.
Declaration
public StarRatingRecommenderEvaluator(IStarRatingRecommenderEvaluatorMapping<TInstanceSource, TUser, TItem, TGroundTruthRating> mapping)
Parameters
Type | Name | Description |
---|---|---|
IStarRatingRecommenderEvaluatorMapping<TInstanceSource, TUser, TItem, TGroundTruthRating> | mapping | The mapping used for accessing data. |
Methods
ConfusionMatrix(TInstanceSource, IDictionary<TUser, IDictionary<TItem, Int32>>, RecommenderMetricAggregationMethod)
Computes a confusion matrix.
Declaration
public RatingMatrix ConfusionMatrix(TInstanceSource instanceSource, IDictionary<TUser, IDictionary<TItem, int>> predictions, RecommenderMetricAggregationMethod aggregationMethod = RecommenderMetricAggregationMethod.Default)
Parameters
Type | Name | Description |
---|---|---|
TInstanceSource | instanceSource | The instance source providing the ground truth. |
IDictionary<TUser, IDictionary<TItem, Int32>> | predictions | A sparse users-by-items matrix of predicted rating distributions. |
RecommenderMetricAggregationMethod | aggregationMethod | A method specifying how metrics are aggregated over the whole dataset. |
Returns
Type | Description |
---|---|
RatingMatrix | The computed confusion matrix. |
ExpectedConfusionMatrix(TInstanceSource, IDictionary<TUser, IDictionary<TItem, IDictionary<Int32, Double>>>, RecommenderMetricAggregationMethod)
Computes the expected confusion matrix.
Declaration
public RatingMatrix ExpectedConfusionMatrix(TInstanceSource instanceSource, IDictionary<TUser, IDictionary<TItem, IDictionary<int, double>>> predictions, RecommenderMetricAggregationMethod aggregationMethod = RecommenderMetricAggregationMethod.Default)
Parameters
Type | Name | Description |
---|---|---|
TInstanceSource | instanceSource | The instance source providing the ground truth. |
IDictionary<TUser, IDictionary<TItem, IDictionary<Int32, Double>>> | predictions | A sparse users-by-items matrix of predicted rating distributions. |
RecommenderMetricAggregationMethod | aggregationMethod | A method specifying how metrics are aggregated over all instances. |
Returns
Type | Description |
---|---|
RatingMatrix | The computed expected confusion matrix. |
ExpectedWeightedConfusion(TInstanceSource, IDictionary<TUser, IDictionary<TItem, IDictionary<Int32, Double>>>, RatingMatrix, RecommenderMetricAggregationMethod)
Computes the expected component-wise product of a confusion matrix and a loss matrix.
Declaration
public double ExpectedWeightedConfusion(TInstanceSource instanceSource, IDictionary<TUser, IDictionary<TItem, IDictionary<int, double>>> predictions, RatingMatrix lossMatrix, RecommenderMetricAggregationMethod aggregationMethod = RecommenderMetricAggregationMethod.Default)
Parameters
Type | Name | Description |
---|---|---|
TInstanceSource | instanceSource | The instance source providing the ground truth (used to compute the expected confusion matrix). |
IDictionary<TUser, IDictionary<TItem, IDictionary<Int32, Double>>> | predictions | A sparse users-by-items matrix of predicted rating distributions (used to compute the expected confusion matrix). |
RatingMatrix | lossMatrix | The loss matrix. |
RecommenderMetricAggregationMethod | aggregationMethod | A method specifying how metrics are aggregated over all instances (used to compute the expected confusion matrix). |
Returns
Type | Description |
---|---|
Double | The computed expected weighted confusion. |
ModelDomainRatingPredictionMetric(TInstanceSource, IDictionary<TUser, IDictionary<TItem, IDictionary<Int32, Double>>>, Func<Int32, IDictionary<Int32, Double>, Double>, RecommenderMetricAggregationMethod)
Computes the average of a given rating prediction metric using ground truth in model domain by iterating over
predictions
and using the aggregation method given in aggregationMethod
.
Declaration
public double ModelDomainRatingPredictionMetric(TInstanceSource instanceSource, IDictionary<TUser, IDictionary<TItem, IDictionary<int, double>>> predictions, Func<int, IDictionary<int, double>, double> metric, RecommenderMetricAggregationMethod aggregationMethod = RecommenderMetricAggregationMethod.Default)
Parameters
Type | Name | Description |
---|---|---|
TInstanceSource | instanceSource | The instance source providing the ground truth. |
IDictionary<TUser, IDictionary<TItem, IDictionary<Int32, Double>>> | predictions | A sparse users-by-items matrix of predicted rating distributions. |
Func<Int32, IDictionary<Int32, Double>, Double> | metric | The rating prediction metric using ground truth in model domain. |
RecommenderMetricAggregationMethod | aggregationMethod | A method specifying how metrics are aggregated over all instances. |
Returns
Type | Description |
---|---|
Double | The computed average of the given rating prediction metric. |
ModelDomainRatingPredictionMetric(TInstanceSource, IDictionary<TUser, IDictionary<TItem, Int32>>, Func<Int32, Int32, Double>, RecommenderMetricAggregationMethod)
Computes the average of a given rating prediction metric using ground truth in model domain by iterating over
predictions
and using the aggregation method given in aggregationMethod
.
Declaration
public double ModelDomainRatingPredictionMetric(TInstanceSource instanceSource, IDictionary<TUser, IDictionary<TItem, int>> predictions, Func<int, int, double> metric, RecommenderMetricAggregationMethod aggregationMethod = RecommenderMetricAggregationMethod.Default)
Parameters
Type | Name | Description |
---|---|---|
TInstanceSource | instanceSource | The instance source providing the ground truth. |
IDictionary<TUser, IDictionary<TItem, Int32>> | predictions | A sparse users-by-items matrix of predicted rating distributions. |
Func<Int32, Int32, Double> | metric | The rating prediction metric using ground truth in model domain. |
RecommenderMetricAggregationMethod | aggregationMethod | A method specifying how metrics are aggregated over all instances. |
Returns
Type | Description |
---|---|
Double | The computed average of the given rating prediction metric. |
ModelDomainRatingPredictionMetricExpectation(TInstanceSource, IDictionary<TUser, IDictionary<TItem, IDictionary<Int32, Double>>>, Func<Int32, Int32, Double>, RecommenderMetricAggregationMethod)
Computes the average of a given rating prediction metric using ground truth in model domain by iterating over
predictions
and using the aggregation method given in aggregationMethod
.
Declaration
public double ModelDomainRatingPredictionMetricExpectation(TInstanceSource instanceSource, IDictionary<TUser, IDictionary<TItem, IDictionary<int, double>>> predictions, Func<int, int, double> metric, RecommenderMetricAggregationMethod aggregationMethod = RecommenderMetricAggregationMethod.Default)
Parameters
Type | Name | Description |
---|---|---|
TInstanceSource | instanceSource | The instance source providing the ground truth. |
IDictionary<TUser, IDictionary<TItem, IDictionary<Int32, Double>>> | predictions | A sparse users-by-items matrix of predicted rating distributions. |
Func<Int32, Int32, Double> | metric | The rating prediction metric using ground truth in model domain. |
RecommenderMetricAggregationMethod | aggregationMethod | A method specifying how metrics are aggregated over all instances. |
Returns
Type | Description |
---|---|
Double | The computed average of the given rating prediction metric. |
ProbabilityCalibrationError(TInstanceSource, IDictionary<TUser, IDictionary<TItem, IDictionary<Int32, Double>>>, Int32, Int32)
Computes the probability calibration error for a given rating.
Declaration
public double ProbabilityCalibrationError(TInstanceSource instanceSource, IDictionary<TUser, IDictionary<TItem, IDictionary<int, double>>> predictions, int rating, int bins)
Parameters
Type | Name | Description |
---|---|---|
TInstanceSource | instanceSource | The instance source providing the ground truth. |
IDictionary<TUser, IDictionary<TItem, IDictionary<Int32, Double>>> | predictions | A sparse users-by-items matrix of predicted rating distributions. |
Int32 | rating | The rating value to generate the calibration plot for. |
Int32 | bins | The number of bins to use. |
Returns
Type | Description |
---|---|
Double | The computed probability calibration error. |
ProbabilityCalibrationPlot(TInstanceSource, IDictionary<TUser, IDictionary<TItem, IDictionary<Int32, Double>>>, Int32, Int32)
Computes the probability calibration plot for a particular rating value.
Declaration
public double[] ProbabilityCalibrationPlot(TInstanceSource instanceSource, IDictionary<TUser, IDictionary<TItem, IDictionary<int, double>>> predictions, int rating, int bins)
Parameters
Type | Name | Description |
---|---|---|
TInstanceSource | instanceSource | The instance source providing the ground truth. |
IDictionary<TUser, IDictionary<TItem, IDictionary<Int32, Double>>> | predictions | A sparse users-by-items matrix of predicted rating distributions. |
Int32 | rating | The rating value to generate the calibration plot for. |
Int32 | bins | The number of bins to use. |
Returns
Type | Description |
---|---|
Double[] | The computed probability calibration plot. |
WeightedConfusion(TInstanceSource, IDictionary<TUser, IDictionary<TItem, Int32>>, RatingMatrix, RecommenderMetricAggregationMethod)
Computes the component-wise product of a confusion matrix and a loss matrix.
Declaration
public double WeightedConfusion(TInstanceSource instanceSource, IDictionary<TUser, IDictionary<TItem, int>> predictions, RatingMatrix lossMatrix, RecommenderMetricAggregationMethod aggregationMethod = RecommenderMetricAggregationMethod.Default)
Parameters
Type | Name | Description |
---|---|---|
TInstanceSource | instanceSource | The instance source providing the ground truth (used to compute the confusion matrix). |
IDictionary<TUser, IDictionary<TItem, Int32>> | predictions | A sparse users-by-items matrix of predicted rating distributions (used to compute the confusion matrix). |
RatingMatrix | lossMatrix | The loss matrix. |
RecommenderMetricAggregationMethod | aggregationMethod | A method specifying how metrics are aggregated over all instances (used to compute the confusion matrix). |
Returns
Type | Description |
---|---|
Double | The computed weighted confusion. |