Interface IRecommender<TInstanceSource, TUser, TItem, TRating, TRatingDistribution, TFeatureSource>
Interface to a recommendation algorithm.
Inherited Members
Namespace: Microsoft.ML.Probabilistic.Learners
Assembly: Microsoft.ML.Probabilistic.Learners.dll
Syntax
public interface IRecommender<in TInstanceSource, TUser, TItem, TRating, TRatingDistribution, in TFeatureSource> : ILearner
Type Parameters
Name | Description |
---|---|
TInstanceSource | The type of a source of instances. |
TUser | The type of a user. |
TItem | The type of an item. |
TRating | The type of a rating. |
TRatingDistribution | The type of a distribution over ratings. |
TFeatureSource | The type of a source of features. |
Remarks
Intended usage:
An instance refers to a single user-item-rating triple. An instance source provides all instances of interest. A feature source provides the features for the users and the items.
Properties
Capabilities
Gets the capabilities of the recommender.
Declaration
IRecommenderCapabilities Capabilities { get; }
Property Value
Type | Description |
---|---|
IRecommenderCapabilities |
ItemSubset
Gets or sets the subset of the items used for related item prediction and recommendation.
Declaration
IEnumerable<TItem> ItemSubset { get; set; }
Property Value
Type | Description |
---|---|
IEnumerable<TItem> |
UserSubset
Gets or sets the subset of the users used for related user prediction.
Declaration
IEnumerable<TUser> UserSubset { get; set; }
Property Value
Type | Description |
---|---|
IEnumerable<TUser> |
Methods
GetRelatedItems(TItem, Int32, TFeatureSource)
Returns a list of items related to item
.
Declaration
IEnumerable<TItem> GetRelatedItems(TItem item, int relatedItemCount, TFeatureSource featureSource = null)
Parameters
Type | Name | Description |
---|---|---|
TItem | item | The item to find related items for. |
Int32 | relatedItemCount | Maximum number of related items to return. |
TFeatureSource | featureSource | The source of features for the specified item. |
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
.
Declaration
IDictionary<TItem, IEnumerable<TItem>> GetRelatedItems(IEnumerable<TItem> items, int relatedItemCount, TFeatureSource featureSource = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TItem> | items | The list of items to find related items for. |
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
.
Declaration
IEnumerable<TUser> GetRelatedUsers(TUser user, int relatedUserCount, TFeatureSource featureSource = null)
Parameters
Type | Name | Description |
---|---|---|
TUser | user | The user to find related users for. |
Int32 | relatedUserCount | Maximum number of related users to return. |
TFeatureSource | featureSource | The source of features for the specified user. |
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
.
Declaration
IDictionary<TUser, IEnumerable<TUser>> GetRelatedUsers(IEnumerable<TUser> users, int relatedUserCount, TFeatureSource featureSource = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TUser> | users | The list of users to find related users for. |
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.
Declaration
IDictionary<TUser, IDictionary<TItem, TRating>> Predict(TInstanceSource instanceSource, TFeatureSource featureSource = null)
Parameters
Type | Name | Description |
---|---|---|
TInstanceSource | instanceSource | The source of instances. |
TFeatureSource | featureSource | The source of features for the specified instances. |
Returns
Type | Description |
---|---|
IDictionary<TUser, IDictionary<TItem, TRating>> | The predicted ratings. |
Predict(TUser, TItem, TFeatureSource)
Predicts a rating for a specified user and item.
Declaration
TRating 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 |
---|---|
TRating | The predicted rating. |
PredictDistribution(TInstanceSource, TFeatureSource)
Predicts rating distributions for the specified instances.
Declaration
IDictionary<TUser, IDictionary<TItem, TRatingDistribution>> PredictDistribution(TInstanceSource instanceSource, TFeatureSource featureSource = null)
Parameters
Type | Name | Description |
---|---|---|
TInstanceSource | instanceSource | The source of instances. |
TFeatureSource | featureSource | The source of the features for the specified instances. |
Returns
Type | Description |
---|---|
IDictionary<TUser, IDictionary<TItem, TRatingDistribution>> | The distributions of the predicted ratings. |
PredictDistribution(TUser, TItem, TFeatureSource)
Predicts the distribution of a rating for a specified user and item.
Declaration
TRatingDistribution 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 specified user and item. |
Returns
Type | Description |
---|---|
TRatingDistribution | The distribution of the rating. |
Recommend(TUser, Int32, TFeatureSource)
Recommends items to a given user.
Declaration
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.
Declaration
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
IEnumerable<Tuple<TItem, TRatingDistribution>> 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, TRatingDistribution>> | 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
IDictionary<TUser, IEnumerable<Tuple<TItem, TRatingDistribution>>> 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, TRatingDistribution>>> | 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.
Declaration
void Train(TInstanceSource instanceSource, TFeatureSource featureSource = null)
Parameters
Type | Name | Description |
---|---|---|
TInstanceSource | instanceSource | The source of instances. |
TFeatureSource | featureSource | The source of features for the specified instances. |