dotnet / dotnet/machinelearning
AveragedPerceptron factory method uses wrong default loss function
- Dominant language
- C#
- Stars
- 9.4k
- Forks
- 2k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 11
Description
**System Information:**
- OS & Version: Windows 11
- ML.NET Version: 3.0.0-preview.23266.6
- .NET Version: .NET 6.0
**Describe the bug**
[StandardTrainersCatalog.AveragedPerceptron](https://github.com/dotnet/machinelearning/blob/09b80f8a08340dc7d79ac75e13c722313f0845eb/src/Microsoft.ML.StandardTrainers/StandardTrainersCatalog.cs#L429C13-L429C196) factory method uses LogLoss as its default loss function, which contradicts method documentation and `AveragedPerceptronTrainer.Options` defaults.
`AveragedPerceptron` method summary states:
> ``The loss function minimized in the training process. If null, HingeLoss would be used and lead to a max-margin averaged perceptron trainer.``
This results in the following inconsistency in behaviour:
```CSharp
// Uses LogLoss:
MLContext.BinaryClassification.Trainers.AveragedPerceptron("Label");
// Uses HingeLoss:
MLContext.BinaryClassification.Trainers.AveragedPerceptron(new AveragedPerceptronTrainer.Options { LabelColumnName = "Label" });
```
**Expected behavior**
2 options:
- Make the non-options `AveragedPerceptron` factory method overload use `HingeLoss` as its default loss function (breaking change).
- Amend the method documentation.
Contributor guide
Assessment
This issue has not been assessed yet.