dotnet / dotnet/machinelearning-samples
"Label" for One-Class Matrix Factorization
- Dominant language
- PowerShell
- Stars
- 4.7k
- Forks
- 2.7k
- Avg merge
- 2d 22h
- Merged PRs (30d)
- 1
Description
There is a sample in this project [MatrixFactorization_ProductRecommendation](https://github.com/dotnet/machinelearning-samples/tree/master/samples/csharp/getting-started/MatrixFactorization_ProductRecommendation) for "One-Class Matrix Factorization"
In this sample `traindata` loaded from 2 column file and added one more `Label` column in the dataset
https://github.com/dotnet/machinelearning-samples/blob/master/samples/csharp/getting-started/MatrixFactorization_ProductRecommendation/ProductRecommender/Program.cs#L31-L39
```csharp
var traindata = mlContext.Data.LoadFromTextFile(path:TrainingDataLocation,
columns: new[]
{
new TextLoader.Column("Label", DataKind.Single, 0), // HERE
new TextLoader.Column(name:nameof(ProductEntry.ProductID), dataKind:DataKind.UInt32, source: new [] { new TextLoader.Range(0) }, keyCount: new KeyCount(262111)),
new TextLoader.Column(name:nameof(ProductEntry.CoPurchaseProductID), dataKind:DataKind.UInt32, source: new [] { new TextLoader.Range(1) }, keyCount: new KeyCount(262111))
},
hasHeader: true,
separatorChar: '\t');
```
when column added it is filled with `NaN`s

According to documentation for [MatrixFactorizationTrainer Class](https://docs.microsoft.com/en-us/dotnet/api/microsoft.ml.trainers.matrixfactorizationtrainer?view=ml-dotnet-preview)
> The coordinate descent method included is specifically for one-class matrix factorization where all observed ratings are positive signals (that is, all rating values are **1**). Notice that the only way to invoke one-class matrix factorization is to assign one-class squared loss to loss function when calling MatrixFactorization(Options). See Page 6 and Page 28 [here](https://www.csie.ntu.edu.tw/%7Ecjlin/talks/facebook.pdf) for a brief introduction to standard matrix factorization and one-class matrix factorization.
Page 28 of [linked paper](https://www.csie.ntu.edu.tw/%7Ecjlin/talks/facebook.pdf) also state that

'One-Class Matrix Factorization' method is used when we know only positive ratings/samples (1s)
**Why `MatrixFactorization_ProductRecommendation` sample does not fill `Label` column with all 1s before matrix factorization?**
// cc @CESARDELATORRE
Update: [Here is more detailed explanation](https://sergeytihon.com/2021/01/05/ml-net-recommendation-engine-pitfall-of-one-class-matrix-factorization/)
Contributor guide
Assessment
This issue has not been assessed yet.