Skip to content

Inconsistency in usage of LossFunction for AveragedPerceptron and OnlineGradientDescent  #2174

Closed
@abgoswam

Description

@abgoswam

The Options class for AveragedPerceptron and OnlineGradientDescent have a field LossFunction which is used as a factory

public sealed class Arguments : AveragedLinearArguments
{
[Argument(ArgumentType.Multiple, HelpText = "Loss Function", ShortName = "loss", SortOrder = 50)]
public ISupportClassificationLossFactory LossFunction = new HingeLoss.Arguments();

public sealed class Arguments : AveragedLinearArguments
{
[Argument(ArgumentType.Multiple, HelpText = "Loss Function", ShortName = "loss", SortOrder = 50)]
[TGUI(Label = "Loss Function")]
public ISupportRegressionLossFactory LossFunction = new SquaredLossFactory();

Instead of using the factory pattern, they should be defined as IClassificationLoss and IRegressionLoss respectively.

That's what the public API also uses:

public static AveragedPerceptronTrainer AveragedPerceptron(
this BinaryClassificationContext.BinaryClassificationTrainers ctx,
string labelColumn = DefaultColumnNames.Label,
string featureColumn = DefaultColumnNames.Features,
string weights = null,
IClassificationLoss lossFunction = null,

Refer to test case OnlineLinearWorkout

@sfilipi

Metadata

Metadata

Assignees

Labels

APIIssues pertaining the friendly API

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions