Class RandomStarRatingRecommender<TInstanceSource, TInstance, TUser, TItem, TDataRating, TFeatureSource, TFeatureValues>
Represents a star rating recommender system which generates predictions purely by random guessing.
Inheritance
Implements
Inherited Members
Namespace: Microsoft.ML.Probabilistic.Learners
Assembly: Microsoft.ML.Probabilistic.Learners.Recommender.dll
Syntax
[SerializationVersion(1)]
public class RandomStarRatingRecommender<TInstanceSource, TInstance, TUser, TItem, TDataRating, TFeatureSource, TFeatureValues> : IRecommender<TInstanceSource, TUser, TItem, int, IDictionary<int, double>, TFeatureSource>, ILearner
Type Parameters
Name | Description |
---|---|
TInstanceSource | The type of a source of instances. |
TInstance | The type of an instance. |
TUser | The type of a user. |
TItem | The type of an item. |
TDataRating | The type of a rating in data. |
TFeatureSource | The type of a feature source. |
TFeatureValues | The type of the feature values. |
Constructors
RandomStarRatingRecommender(IStarRatingRecommenderMapping<TInstanceSource, TInstance, TUser, TItem, TDataRating, TFeatureSource, TFeatureValues>)
Initializes a new instance of the RandomStarRatingRecommender<TInstanceSource, TInstance, TUser, TItem, TDataRating, TFeatureSource, TFeatureValues> class.
Declaration
public RandomStarRatingRecommender(IStarRatingRecommenderMapping<TInstanceSource, TInstance, TUser, TItem, TDataRating, TFeatureSource, TFeatureValues> mapping)
Parameters
Type | Name | Description |
---|---|---|
IStarRatingRecommenderMapping<TInstanceSource, TInstance, TUser, TItem, TDataRating, TFeatureSource, TFeatureValues> | mapping | The mapping used to access the data. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if one of the required parameters is null. |
Properties
Capabilities
Gets the capabilities of the recommender.
Declaration
public IRecommenderCapabilities Capabilities { get; }
Property Value
Type | Description |
---|---|
IRecommenderCapabilities |
ItemSubset
Gets or sets the subset of the items used for related item prediction and item recommendation.
Declaration
public IEnumerable<TItem> ItemSubset { get; set; }
Property Value
Type | Description |
---|---|
IEnumerable<TItem> |
Settings
Gets or sets the settings (not supported).
Declaration
public ISettings Settings { get; set; }
Property Value
Type | Description |
---|---|
ISettings |
UserSubset
Gets or sets the subset of the users used for related user prediction.
Declaration
public IEnumerable<TUser> UserSubset { get; set; }
Property Value
Type | Description |
---|---|
IEnumerable<TUser> |
Methods
GetRelatedItems(TItem, Int32, TFeatureSource)
Returns a list of items related to item
by randomly permuting the ItemSubset.
Declaration
public IEnumerable<TItem> GetRelatedItems(TItem item, int relatedItemCount, TFeatureSource featureSource = null)
Parameters
Type | Name | Description |
---|---|---|
TItem | item | The item for which related items should be found. |
Int32 | relatedItemCount | Maximum number of related items to return. |
TFeatureSource | featureSource | The source of features for the items. |
Returns
Type | Description |
---|---|
IEnumerable<TItem> | The list of related items. |
Remarks
Only items specified in ItemSubset will be returned.
GetRelatedItems(IEnumerable<TItem>, Int32, TFeatureSource)
Returns a list of related items to each item in items
by randomly permuting the ItemSubset.
Declaration
public IDictionary<TItem, IEnumerable<TItem>> GetRelatedItems(IEnumerable<TItem> items, int relatedItemCount, TFeatureSource featureSource = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TItem> | items | The list of items for which related items should be found. |
Int32 | relatedItemCount | Maximum number of related items to return for every item. |
TFeatureSource | featureSource | The source of features for the specified items. |
Returns
Type | Description |
---|---|
IDictionary<TItem, IEnumerable<TItem>> | The list of related items for each item from |
Remarks
Only items specified in ItemSubset will be returned.
GetRelatedUsers(TUser, Int32, TFeatureSource)
Returns a list of users related to user
by randomly permuting the UserSubset.
Declaration
public IEnumerable<TUser> GetRelatedUsers(TUser user, int relatedUserCount, TFeatureSource featureSource = null)
Parameters
Type | Name | Description |
---|---|---|
TUser | user | The user for which related users should be found. |
Int32 | relatedUserCount | Maximum number of related users to return. |
TFeatureSource | featureSource | The source of features for the users. |
Returns
Type | Description |
---|---|
IEnumerable<TUser> | The list of related users. |
Remarks
Only users specified in UserSubset will be returned.
GetRelatedUsers(IEnumerable<TUser>, Int32, TFeatureSource)
Returns a list of related users to each user in users
by randomly permuting the UserSubset.
Declaration
public IDictionary<TUser, IEnumerable<TUser>> GetRelatedUsers(IEnumerable<TUser> users, int relatedUserCount, TFeatureSource featureSource = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TUser> | users | The list of users for which related users should be found. |
Int32 | relatedUserCount | Maximum number of related users to return for every user. |
TFeatureSource | featureSource | The source of features for the specified users. |
Returns
Type | Description |
---|---|
IDictionary<TUser, IEnumerable<TUser>> | The list of related users for each user from |
Remarks
Only users specified in UserSubset will be returned.
Predict(TInstanceSource, TFeatureSource)
Predicts ratings for the specified instances by random guessing.
Declaration
public IDictionary<TUser, IDictionary<TItem, int>> Predict(TInstanceSource instanceSource, TFeatureSource featureSource = null)
Parameters
Type | Name | Description |
---|---|---|
TInstanceSource | instanceSource | The instances to predict ratings for. |
TFeatureSource | featureSource | The source of features for the specified instances. |
Returns
Type | Description |
---|---|
IDictionary<TUser, IDictionary<TItem, Int32>> | The predicted ratings. |
Predict(TUser, TItem, TFeatureSource)
Predicts rating for a given user and item by random guessing.
Declaration
public int Predict(TUser user, TItem item, TFeatureSource featureSource = null)
Parameters
Type | Name | Description |
---|---|---|
TUser | user | The user. |
TItem | item | The item. |
TFeatureSource | featureSource | The source of features for the specified user and item. |
Returns
Type | Description |
---|---|
Int32 | The predicted rating. |
PredictDistribution(TInstanceSource, TFeatureSource)
Predicts rating distributions for the specified instances by returning the uniform distribution over the possible rating values.
Declaration
public IDictionary<TUser, IDictionary<TItem, IDictionary<int, double>>> PredictDistribution(TInstanceSource instanceSource, TFeatureSource featureSource = null)
Parameters
Type | Name | Description |
---|---|---|
TInstanceSource | instanceSource | The instances to predict ratings for. |
TFeatureSource | featureSource | The source of features for the specified instances. |
Returns
Type | Description |
---|---|
IDictionary<TUser, IDictionary<TItem, IDictionary<Int32, Double>>> | The distributions of the predicted ratings. |
PredictDistribution(TUser, TItem, TFeatureSource)
Predicts the distribution of a rating for a given user and item by returning a random distribution over ratings.
Declaration
public IDictionary<int, double> PredictDistribution(TUser user, TItem item, TFeatureSource featureSource = null)
Parameters
Type | Name | Description |
---|---|---|
TUser | user | The user. |
TItem | item | The item. |
TFeatureSource | featureSource | The source of features for the given user and item. |
Returns
Type | Description |
---|---|
IDictionary<Int32, Double> | The distribution of the rating. |
Recommend(TUser, Int32, TFeatureSource)
Recommends items to a given user by randomly permuting the ItemSubset.
Declaration
public IEnumerable<TItem> Recommend(TUser user, int recommendationCount, TFeatureSource featureSource = null)
Parameters
Type | Name | Description |
---|---|---|
TUser | user | The user to recommend items to. |
Int32 | recommendationCount | Maximum number of items to recommend. |
TFeatureSource | featureSource | The source of features for the specified user. |
Returns
Type | Description |
---|---|
IEnumerable<TItem> | The list of recommended items. |
Remarks
Only items specified in ItemSubset can be recommended.
Recommend(IEnumerable<TUser>, Int32, TFeatureSource)
Recommends items to a given list of users by randomly permuting the ItemSubset.
Declaration
public IDictionary<TUser, IEnumerable<TItem>> Recommend(IEnumerable<TUser> users, int recommendationCount, TFeatureSource featureSource = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TUser> | users | The list of users to recommend items to. |
Int32 | recommendationCount | Maximum number of items to recommend to a single user. |
TFeatureSource | featureSource | The source of features for the specified users. |
Returns
Type | Description |
---|---|
IDictionary<TUser, IEnumerable<TItem>> | The list of recommended items for every user from |
Remarks
Only items specified in ItemSubset can be recommended.
RecommendDistribution(TUser, Int32, TFeatureSource)
Recommend items with their rating distributions to a specified user.
Declaration
public IEnumerable<Tuple<TItem, IDictionary<int, double>>> RecommendDistribution(TUser user, int recommendationCount, TFeatureSource featureSource = null)
Parameters
Type | Name | Description |
---|---|---|
TUser | user | The user to recommend items to. |
Int32 | recommendationCount | Maximum number of items to recommend. |
TFeatureSource | featureSource | The source of features for the specified user. |
Returns
Type | Description |
---|---|
IEnumerable<Tuple<TItem, IDictionary<Int32, Double>>> | The list of recommended items and their rating distributions. |
Remarks
Only items specified in ItemSubset can be recommended.
RecommendDistribution(IEnumerable<TUser>, Int32, TFeatureSource)
Recommends items with their rating distributions to a specified list of users.
Declaration
public IDictionary<TUser, IEnumerable<Tuple<TItem, IDictionary<int, double>>>> RecommendDistribution(IEnumerable<TUser> users, int recommendationCount, TFeatureSource featureSource = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TUser> | users | The list of users to recommend items to. |
Int32 | recommendationCount | Maximum number of items to recommend to a single user. |
TFeatureSource | featureSource | The source of features for the specified users. |
Returns
Type | Description |
---|---|
IDictionary<TUser, IEnumerable<Tuple<TItem, IDictionary<Int32, Double>>>> | The list of recommended items and their rating distributions for every user from |
Remarks
Only items specified in ItemSubset can be recommended.
Train(TInstanceSource, TFeatureSource)
Trains the recommender on the specified instances. For the random recommender it results in just retrieving the rating info, as well as the list of items and users from the training set.
Declaration
public void Train(TInstanceSource instanceSource, TFeatureSource featureSource = null)
Parameters
Type | Name | Description |
---|---|---|
TInstanceSource | instanceSource | The source of instances to train on. |
TFeatureSource | featureSource | The source of features for the specified instances. |
Explicit Interface Implementations
ILearner.Capabilities
Gets the capabilities of the learner. These are any properties of the learner that are not captured by the type signature of the most specific learner interface below.
Declaration
ICapabilities ILearner.Capabilities { get; }
Returns
Type | Description |
---|---|
ICapabilities |