Class NegativeDataGeneratorMapping<TInstanceSource, TInstance, TUser, TItem, TFeatureSource, TFeatureValues>
Represents a generator of negative ratings.
Inheritance
Implements
Inherited Members
Namespace: Microsoft.ML.Probabilistic.Learners.Mappings
Assembly: Microsoft.ML.Probabilistic.Learners.Recommender.dll
Syntax
[Serializable]
public class NegativeDataGeneratorMapping<TInstanceSource, TInstance, TUser, TItem, TFeatureSource, TFeatureValues> : IStarRatingRecommenderMapping<TInstanceSource, RatingInstance<TUser, TItem, byte>, TUser, TItem, int, TFeatureSource, TFeatureValues>, IRatingRecommenderMapping<TInstanceSource, RatingInstance<TUser, TItem, byte>, TUser, TItem, int, TFeatureSource, TFeatureValues>, IRecommenderMapping<TInstanceSource, RatingInstance<TUser, TItem, byte>, TUser, TItem, TFeatureSource, TFeatureValues>, ICustomSerializable
Type Parameters
Name | Description |
---|---|
TInstanceSource | The type of an instance source. |
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
A description of the algorithm for negative data generation used here can be found in Section 4.1 of this paper.
Constructors
NegativeDataGeneratorMapping(IRecommenderMapping<TInstanceSource, TInstance, TUser, TItem, TFeatureSource, TFeatureValues>, Double)
Initializes a new instance of the NegativeDataGeneratorMapping<TInstanceSource, TInstance, TUser, TItem, TFeatureSource, TFeatureValues> class.
Declaration
public NegativeDataGeneratorMapping(IRecommenderMapping<TInstanceSource, TInstance, TUser, TItem, TFeatureSource, TFeatureValues> mapping, double itemHistogramAdjustment = 1.2)
Parameters
Type | Name | Description |
---|---|---|
IRecommenderMapping<TInstanceSource, TInstance, TUser, TItem, TFeatureSource, TFeatureValues> | mapping | The top level mapping. |
Double | itemHistogramAdjustment | The degree to which each element of the item histogram is raised before sampling. Should be different from 1.0 if it is believed that there is some quality bar which drives popular items to be more generally liked. |
NegativeDataGeneratorMapping(IReader, IRecommenderMapping<TInstanceSource, TInstance, TUser, TItem, TFeatureSource, TFeatureValues>)
Initializes a new instance of the NegativeDataGeneratorMapping<TInstanceSource, TInstance, TUser, TItem, TFeatureSource, TFeatureValues> class from a reader of a binary stream.
Declaration
public NegativeDataGeneratorMapping(IReader reader, IRecommenderMapping<TInstanceSource, TInstance, TUser, TItem, TFeatureSource, TFeatureValues> mapping)
Parameters
Type | Name | Description |
---|---|---|
IReader | reader | The binary reader to read the state of the negative data generation mapping from. |
IRecommenderMapping<TInstanceSource, TInstance, TUser, TItem, TFeatureSource, TFeatureValues> | mapping | The top level mapping. |
Methods
GetInstances(TInstanceSource)
Retrieves a list of instances from a given instance source.
Declaration
public IEnumerable<RatingInstance<TUser, TItem, byte>> GetInstances(TInstanceSource instanceSource)
Parameters
Type | Name | Description |
---|---|---|
TInstanceSource | instanceSource | The instance source to retrieve instances from. |
Returns
Type | Description |
---|---|
IEnumerable<RatingInstance<TUser, TItem, Byte>> | The list of retrieved instances. |
GetItem(TInstanceSource, RatingInstance<TUser, TItem, Byte>)
Extracts an item from a given instance.
Declaration
public TItem GetItem(TInstanceSource instanceSource, RatingInstance<TUser, TItem, byte> instance)
Parameters
Type | Name | Description |
---|---|---|
TInstanceSource | instanceSource | The instance source providing the |
RatingInstance<TUser, TItem, Byte> | 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.
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 |
GetRating(TInstanceSource, RatingInstance<TUser, TItem, Byte>)
Extracts a rating from a given instance.
Declaration
public int GetRating(TInstanceSource instanceSource, RatingInstance<TUser, TItem, byte> instance)
Parameters
Type | Name | Description |
---|---|---|
TInstanceSource | instanceSource | The instance source providing the |
RatingInstance<TUser, TItem, Byte> | instance | The instance to extract the rating from. |
Returns
Type | Description |
---|---|
Int32 | The extracted rating. |
GetRatingInfo(TInstanceSource)
Provides the object describing how ratings in the dataset map to the stars.
Declaration
public IStarRatingInfo<int> GetRatingInfo(TInstanceSource instanceSource)
Parameters
Type | Name | Description |
---|---|---|
TInstanceSource | instanceSource | The instance source. |
Returns
Type | Description |
---|---|
IStarRatingInfo<Int32> | The object describing how ratings provided by the instance source map to stars. |
GetUser(TInstanceSource, RatingInstance<TUser, TItem, Byte>)
Extracts a user from a given instance.
Declaration
public TUser GetUser(TInstanceSource instanceSource, RatingInstance<TUser, TItem, byte> instance)
Parameters
Type | Name | Description |
---|---|---|
TInstanceSource | instanceSource | The instance source providing the |
RatingInstance<TUser, TItem, Byte> | 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.
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 |
SaveForwardCompatible(IWriter)
Saves the negative data generation mapping using the specified writer to a binary stream.
Declaration
public void SaveForwardCompatible(IWriter writer)
Parameters
Type | Name | Description |
---|---|---|
IWriter | writer | The writer to save the negative data generation mapping to. |