Interface IMatchboxRecommenderMapping<TInstanceSource, TFeatureSource>
A mapping used by the implementations of IMatchboxRecommender<TInstanceSource, TUser, TItem, TRatingDistribution, TFeatureSource> interface to convert user data to an appropriate format.
Namespace: Microsoft.ML.Probabilistic.Learners.Mappings
Assembly: Microsoft.ML.Probabilistic.Learners.Recommender.dll
Syntax
public interface IMatchboxRecommenderMapping<in TInstanceSource, in TFeatureSource>
Type Parameters
Name | Description |
---|---|
TInstanceSource | The type of a source of instances. |
TFeatureSource | The type of a source of features. |
Remarks
Feature-related methods in this interface are only called when user of item features are being used. During training, features for all entities are required, and hence the methods called are the GetAllFeature ones. During prediction, features are requested on per-entity basis, and hence the GetSingleFeature methods are called. Note that entity features are expected not to change between training and prediction, and therefore only features of cold users or items will be requested during prediction.
Methods
GetAllItemNonZeroFeatureIndices(TFeatureSource)
Gets non-zero feature indices for all items present in a given feature source.
Declaration
IReadOnlyList<IReadOnlyList<int>> GetAllItemNonZeroFeatureIndices(TFeatureSource featureSource)
Parameters
Type | Name | Description |
---|---|---|
TFeatureSource | featureSource | The source to obtain feature indices from. |
Returns
Type | Description |
---|---|
IReadOnlyList<IReadOnlyList<Int32>> | An array of non-zero item feature index arrays where the outer array is indexed by item id |
Remarks
This function will be called during training if the item feature support is enabled.
GetAllItemNonZeroFeatureValues(TFeatureSource)
Gets non-zero feature values for all items present in a given feature source.
Declaration
IReadOnlyList<IReadOnlyList<double>> GetAllItemNonZeroFeatureValues(TFeatureSource featureSource)
Parameters
Type | Name | Description |
---|---|---|
TFeatureSource | featureSource | The source to obtain features from. |
Returns
Type | Description |
---|---|
IReadOnlyList<IReadOnlyList<Double>> | An array of non-zero item feature arrays where the outer array is indexed by item id |
Remarks
This function will be called during training if the item feature support is enabled.
GetAllUserNonZeroFeatureIndices(TFeatureSource)
Gets non-zero feature indices for all users present in a given feature source.
Declaration
IReadOnlyList<IReadOnlyList<int>> GetAllUserNonZeroFeatureIndices(TFeatureSource featureSource)
Parameters
Type | Name | Description |
---|---|---|
TFeatureSource | featureSource | The source to obtain feature indices from. |
Returns
Type | Description |
---|---|
IReadOnlyList<IReadOnlyList<Int32>> | An array of non-zero user feature index arrays where the outer array is indexed by user id. |
Remarks
This function will be called during training if the user feature support is enabled.
GetAllUserNonZeroFeatureValues(TFeatureSource)
Gets non-zero feature values for all users present in a given feature source.
Declaration
IReadOnlyList<IReadOnlyList<double>> GetAllUserNonZeroFeatureValues(TFeatureSource featureSource)
Parameters
Type | Name | Description |
---|---|---|
TFeatureSource | featureSource | The source to obtain features from. |
Returns
Type | Description |
---|---|
IReadOnlyList<IReadOnlyList<Double>> | An array of non-zero user feature arrays where the outer array is indexed by user id. |
Remarks
This function will be called during training if the user feature support is enabled.
GetItemCount(TInstanceSource)
Gets the number of items from a given instance source.
Declaration
int GetItemCount(TInstanceSource instanceSource)
Parameters
Type | Name | Description |
---|---|---|
TInstanceSource | instanceSource | The source of instances to get number of items from. |
Returns
Type | Description |
---|---|
Int32 | The number of items. |
GetItemFeatureCount(TFeatureSource)
Gets the number of item features.
Declaration
int GetItemFeatureCount(TFeatureSource featureSource)
Parameters
Type | Name | Description |
---|---|---|
TFeatureSource | featureSource | The source to obtain features from. |
Returns
Type | Description |
---|---|
Int32 | The number of item features. |
GetItemIds(TInstanceSource, Int32)
Gets the list of item identifiers from a given instance source.
Declaration
IReadOnlyList<int> GetItemIds(TInstanceSource instanceSource, int batchNumber = 0)
Parameters
Type | Name | Description |
---|---|---|
TInstanceSource | instanceSource | The source of instances to get the item identifiers from. |
Int32 | batchNumber | The number of the current batch (used only if the data is divided into batches). |
Returns
Type | Description |
---|---|
IReadOnlyList<Int32> | The list of item identifiers. |
Remarks
Note that this method can be called concurrently from multiple threads, so its implementation must be thread-safe.
GetRatingCount(TInstanceSource)
Gets the number of star ratings. This is equal to one plus the difference between the maximum and the minimum rating.
Declaration
int GetRatingCount(TInstanceSource instanceSource)
Parameters
Type | Name | Description |
---|---|---|
TInstanceSource | instanceSource | The source of instances to get number of items from. |
Returns
Type | Description |
---|---|
Int32 | The number of ratings. |
GetRatings(TInstanceSource, Int32)
Gets the list of ratings from a given instance source.
Declaration
IReadOnlyList<int> GetRatings(TInstanceSource instanceSource, int batchNumber = 0)
Parameters
Type | Name | Description |
---|---|---|
TInstanceSource | instanceSource | The source of instances to get the ratings from. |
Int32 | batchNumber | The number of the current batch (used only if the data is divided into batches). |
Returns
Type | Description |
---|---|
IReadOnlyList<Int32> | The list of ratings |
Remarks
Note that this method can be called concurrently from multiple threads, so its implementation must be thread-safe.
GetSingleItemNonZeroFeatureIndices(TFeatureSource, Int32)
Gets non-zero feature indices for a given item.
Declaration
IReadOnlyList<int> GetSingleItemNonZeroFeatureIndices(TFeatureSource featureSource, int itemId)
Parameters
Type | Name | Description |
---|---|---|
TFeatureSource | featureSource | The source to obtain feature indices from. |
Int32 | itemId | The item identifier. |
Returns
Type | Description |
---|---|
IReadOnlyList<Int32> | Non-zero feature values for the item. |
Remarks
This function will be called during prediction for cold items if the item feature support is enabled.
GetSingleItemNonZeroFeatureValues(TFeatureSource, Int32)
Gets non-zero feature values for a given item.
Declaration
IReadOnlyList<double> GetSingleItemNonZeroFeatureValues(TFeatureSource featureSource, int itemId)
Parameters
Type | Name | Description |
---|---|---|
TFeatureSource | featureSource | The source to obtain features from. |
Int32 | itemId | The item identifier. |
Returns
Type | Description |
---|---|
IReadOnlyList<Double> | Non-zero feature values for the item. |
Remarks
This function will be called during prediction for cold items if the item feature support is enabled.
GetSingleUserNonZeroFeatureIndices(TFeatureSource, Int32)
Gets non-zero feature indices for a given user.
Declaration
IReadOnlyList<int> GetSingleUserNonZeroFeatureIndices(TFeatureSource featureSource, int userId)
Parameters
Type | Name | Description |
---|---|---|
TFeatureSource | featureSource | The source to obtain feature indices from. |
Int32 | userId | The user identifier. |
Returns
Type | Description |
---|---|
IReadOnlyList<Int32> | Non-zero feature indices for the user. |
Remarks
This function will be called during prediction for cold users if the user feature support is enabled.
GetSingleUserNonZeroFeatureValues(TFeatureSource, Int32)
Gets non-zero feature values for a given user.
Declaration
IReadOnlyList<double> GetSingleUserNonZeroFeatureValues(TFeatureSource featureSource, int userId)
Parameters
Type | Name | Description |
---|---|---|
TFeatureSource | featureSource | The source to obtain features from. |
Int32 | userId | The user identifier. |
Returns
Type | Description |
---|---|
IReadOnlyList<Double> | Non-zero feature values for the user. |
Remarks
This function will be called during prediction for cold users if the user feature support is enabled.
GetUserCount(TInstanceSource)
Gets the number of users from a given instance source.
Declaration
int GetUserCount(TInstanceSource instanceSource)
Parameters
Type | Name | Description |
---|---|---|
TInstanceSource | instanceSource | The source of instances to get number of users from. |
Returns
Type | Description |
---|---|
Int32 | The number of users. |
GetUserFeatureCount(TFeatureSource)
Gets the number of user features.
Declaration
int GetUserFeatureCount(TFeatureSource featureSource)
Parameters
Type | Name | Description |
---|---|---|
TFeatureSource | featureSource | The source to obtain features from. |
Returns
Type | Description |
---|---|
Int32 | The number of user features. |
GetUserIds(TInstanceSource, Int32)
Gets the list of user identifiers from a given instance source.
Declaration
IReadOnlyList<int> GetUserIds(TInstanceSource instanceSource, int batchNumber = 0)
Parameters
Type | Name | Description |
---|---|---|
TInstanceSource | instanceSource | The source of instances to get the user identifiers from. |
Int32 | batchNumber | The number of the current batch (used only if the data is divided into batches). |
Returns
Type | Description |
---|---|
IReadOnlyList<Int32> | The list of user identifiers. |
Remarks
Note that this method can be called concurrently from multiple threads, so its implementation must be thread-safe.