Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change default EvaluationMetric for LightGbm trainers to conform to d… #3859

Merged
merged 1 commit into from
Jul 1, 2019

Conversation

najeeb-kazmi
Copy link
Member

@najeeb-kazmi najeeb-kazmi commented Jun 13, 2019

…efault metric in standalone LightGbm

Fixes #3822

In ML.NET, the default EvaluationMetric for LightGbm is set to EvaluateMetricType.Error for multiclass, EvaluationMetricType.LogLoss for binary, and so on. This leads to inconsistent behavior from the user's perspective: If a user specified EvaluationMetric = EvaluateMetricType.Default, the parameter passed to LightGbm would be the empty string "", which is the LightGbm default and means that the metric is selected based on the objective. However, if they do not specify EvaluationMetric at all, the parameter passed to LightGbm would be Error for multiclass, LogLoss for binary, and so on.

We should make the experience for LightGbm in ML.NET consistent with what a user of standalone LightGbm experiences, and not expect them to dig through LightGbm docs and ML.NET docs to find this out.

This PR makes the user experience consistent with standalone LightGbm by by changing the default EvaluationMetric in ML.NET to EvaluationMetricType.Default.

LightGbm metric parameters docs

@@ -162,7 +162,7 @@ public enum EvaluateMetricType
[Argument(ArgumentType.AtMostOnce,
HelpText = "Evaluation metrics.",
ShortName = "em")]
public EvaluateMetricType EvaluationMetric = EvaluateMetricType.Logloss;
public EvaluateMetricType EvaluationMetric = EvaluateMetricType.Default;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default [](start = 76, length = 7)

Isn't this a breaking change?
cc @eerhardt

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but the other option is to have an inconsistent user experience. I talked to @ebarsoumMS about this. Let's discuss and reach a conclusion.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not an "API breaking change". I think it falls into the scenarios that @TomFinley listed here #3602 (comment).

However even many years later sometimes we still have somewhat troublesome defaults running around

Here, if there is a better default value, I think it is acceptable to change the default.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this doesn't actually change training behavior, nor the metrics calculated by ML.NET evaluators. Just changes the metric that LightGbm calculates internally.

In ML.NET, when we do the following (e.g. for binary classification)

var transformedTestData = model.Transform(testData);
var metrics = mlContext.BinaryClassification.Evaluate(transformedTestData);

the evaluator computes all relevant metrics for binary classification regardless of what is specified by LightGbm's EvaluationMetric parameter.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may control LightGBM's early stopping, but otherwise I think this is a NOOP change. ML.NET doesn't relay the stdout from LightGBM to the user, and ML.NET uses its own evaluators for computing the final metrics.

Users could benefit from ML.NET relaying this info back to the user. This would allow a GUI to show the learning curves in real time (or as text output from a CLI):

Copy link

@yaeldekel yaeldekel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

Copy link
Member

@codemzs codemzs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@codemzs codemzs merged commit 3a35a82 into dotnet:master Jul 1, 2019
codemzs added a commit to codemzs/machinelearning that referenced this pull request Jul 3, 2019
…orm to default metric in standalone LightGbm (dotnet#3859)"

This reverts commit 3a35a82.
Dmitry-A pushed a commit to Dmitry-A/machinelearning that referenced this pull request Jul 24, 2019
@najeeb-kazmi najeeb-kazmi deleted the 3822 branch January 30, 2020 01:23
@ghost ghost locked as resolved and limited conversation to collaborators Mar 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LightGbm default evaluation metrics in ML.NET do not conform to standalone LightGbm
5 participants