Class TrainTestSplittingRecommenderMapping<TInstanceSource, TInstance, TUser, TItem, TFeatureSource, TFeatureValues>
Represents the data splitting mapping that can be wrapped around any other recommender mapping to split the underlying data into the training and test parts.
Inheritance
Implements
Inherited Members
Namespace: Microsoft.ML.Probabilistic.Learners.Mappings
Assembly: Microsoft.ML.Probabilistic.Learners.Recommender.dll
Syntax
public class TrainTestSplittingRecommenderMapping<TInstanceSource, TInstance, TUser, TItem, TFeatureSource, TFeatureValues> : IRecommenderMapping<SplitInstanceSource<TInstanceSource>, TInstance, TUser, TItem, TFeatureSource, TFeatureValues>
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. |
TFeatureSource | The type of a feature source. |
TFeatureValues | The type of the feature values. |
Remarks
- The requested fraction of items is removed from the consideration (thus, ignored) with all the associated observations.
- The requested fraction of items is put into the test set (so called cold items) with all the associated observations.
- The requested fraction of the users remaining after (1-2) is removed from consideration (thus, ignored) with all the associated observations.
- The requested fraction of the users remaining after (1-2) is put into the test set (so called cold users) with all the associated observations.
- The requested fraction of the users remaining after (1-2) is put into the training set with all the associated observations.
- For each user remaining after (1-5) the requested fraction of observations is put into the training set, while the rest is put into the test set. At least one observation is always put into the training set for each user.
- If requested, instances associated with the occasionally produced cold items are removed from the test set. An item is said to be "occasionally cold" if it is covered only by the test set but wasn't explicitly chosen as cold. Such items can be produced by the steps (4) and (6). This option is supposed to be used when the requested number of cold users and items is set to zero, in order to ensure that all the entities in the test set are covered by the training set.
Constructors
TrainTestSplittingRecommenderMapping(IRecommenderMapping<TInstanceSource, TInstance, TUser, TItem, TFeatureSource, TFeatureValues>, Double, Double, Double, Double, Double, Double, Boolean)
Initializes a new instance of the TrainTestSplittingRecommenderMapping<TInstanceSource, TInstance, TUser, TItem, TFeatureSource, TFeatureValues> class.
Declaration
public TrainTestSplittingRecommenderMapping(IRecommenderMapping<TInstanceSource, TInstance, TUser, TItem, TFeatureSource, TFeatureValues> mapping, double trainingOnlyUserFraction, double testUserRatingTrainingFraction, double coldUserFraction = 0, double coldItemFraction = 0, double ignoredUserFraction = 0, double ignoredItemFraction = 0, bool removeOccasionalColdItems = false)
Parameters
Type | Name | Description |
---|---|---|
IRecommenderMapping<TInstanceSource, TInstance, TUser, TItem, TFeatureSource, TFeatureValues> | mapping | The wrapped recommender mapping. |
Double | trainingOnlyUserFraction | The fraction of users included in the training set only. |
Double | testUserRatingTrainingFraction | The fraction of ratings in the training set for each user who is presented in both sets. |
Double | coldUserFraction | The fraction of users included in the test set only. |
Double | coldItemFraction | The fraction of items included in the test set only. |
Double | ignoredUserFraction | The fraction of users not included in either the training or the test set. |
Double | ignoredItemFraction | The fraction of items not included in either the training or the test set. |
Boolean | removeOccasionalColdItems | Whether the occasionally produced cold items should be removed from the test set. |
Methods
GetInstances(SplitInstanceSource<TInstanceSource>)
Retrieves a list of instances from a given instance source. Dependent on IsTrainingSet, the instances of the training or test set are returned.
Declaration
public IEnumerable<TInstance> GetInstances(SplitInstanceSource<TInstanceSource> instanceSource)
Parameters
Type | Name | Description |
---|---|---|
SplitInstanceSource<TInstanceSource> | instanceSource | The source to retrieve instances from. |
Returns
Type | Description |
---|---|
IEnumerable<TInstance> | The list of retrieved instances. |
GetItem(SplitInstanceSource<TInstanceSource>, TInstance)
Extracts an item from a given instance by delegating the call to the wrapped mapping.
Declaration
public TItem GetItem(SplitInstanceSource<TInstanceSource> instanceSource, TInstance instance)
Parameters
Type | Name | Description |
---|---|---|
SplitInstanceSource<TInstanceSource> | instanceSource | The source of instances providing the |
TInstance | instance | The instance to extract the item from. |
Returns
Type | Description |
---|---|
TItem | The extracted item. |
GetItemFeatures(TFeatureSource, TItem)
Provides the features for a given item by delegating the call to the wrapped mapping.
Declaration
public TFeatureValues GetItemFeatures(TFeatureSource featureSource, TItem item)
Parameters
Type | Name | Description |
---|---|---|
TFeatureSource | featureSource | The source of the features. |
TItem | item | The item to provide the features for. |
Returns
Type | Description |
---|---|
TFeatureValues | The features for |
GetUser(SplitInstanceSource<TInstanceSource>, TInstance)
Extracts a user from a given instance by delegating the call to the wrapped mapping.
Declaration
public TUser GetUser(SplitInstanceSource<TInstanceSource> instanceSource, TInstance instance)
Parameters
Type | Name | Description |
---|---|---|
SplitInstanceSource<TInstanceSource> | instanceSource | The source of instances providing the |
TInstance | instance | The instance to extract the user from. |
Returns
Type | Description |
---|---|
TUser | The extracted user. |
GetUserFeatures(TFeatureSource, TUser)
Provides the features for a given user by delegating the call to the wrapped mapping.
Declaration
public TFeatureValues GetUserFeatures(TFeatureSource featureSource, TUser user)
Parameters
Type | Name | Description |
---|---|---|
TFeatureSource | featureSource | The source of the features. |
TUser | user | The user to provide the features for. |
Returns
Type | Description |
---|---|
TFeatureValues | The features for |