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

AutoMM early stopping with a threshold #2633

Merged
merged 5 commits into from
Jan 5, 2023

Conversation

zhiqiangdon
Copy link
Contributor

Issue #, if available:
#2555 #2629

Description of changes:
Early stopping if reaching a perfect score. Can't use exactly 1 or 0 due to the precision issues. Tested it with the example in #2629.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@github-actions
Copy link

github-actions bot commented Jan 4, 2023

Job PR-2633-3712bb1 is done.
Docs are uploaded to http://autogluon-staging.s3-website-us-west-2.amazonaws.com/PR-2633/3712bb1/index.html

@@ -1261,6 +1261,7 @@ def _fit(
monitor=task.validation_metric_name,
patience=config.optimization.patience,
mode=minmax_mode,
stopping_threshold=1 - 1e-6 if minmax_mode == MAX else 1e-6,
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we assuming all positive-is-better metrics have an optimal score of 1? I guess in general this is true, but it is a pretty flimsy assumption especially if a user can provide a custom metric. Ditto for assuming optimal score of 0 for negative-is-better metrics.

These situations are handled in my autogluon.core.metrics logic, where each metric has a defined optimum value.

Copy link
Contributor

Choose a reason for hiding this comment

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

Beyond the above point, the fact we need an if here seems like unnecessary code bloat and increases risk of bugs. It would be better if the optimum value / minmax_mode was simply provided by the metric itself, rather than hard-coded into this line.

Copy link
Contributor

Choose a reason for hiding this comment

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

for example:

stopping_threshold = metric.optimum - metric.sign * epsilon
which translates to:
stopping_threshold = 1 - (1 * 1e-6)

I think this would be a lot cleaner.

Both of these things are provided in autogluon.core.metrics.

from autogluon.core.metrics import roc_auc

epsilon = 1e-6
stopping_threshold = roc_auc.optimum - roc_auc._sign * epsilon

print(stopping_threshold)
0.999999

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good suggestion. Thanks.

Copy link
Collaborator

@sxjscience sxjscience left a comment

Choose a reason for hiding this comment

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

LGTM

@github-actions
Copy link

github-actions bot commented Jan 5, 2023

Job PR-2633-fd4f17c is done.
Docs are uploaded to http://autogluon-staging.s3-website-us-west-2.amazonaws.com/PR-2633/fd4f17c/index.html

@sxjscience sxjscience merged commit 95f0e8f into autogluon:master Jan 5, 2023
@zhiqiangdon zhiqiangdon deleted the mm-early-stop branch January 5, 2023 06:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants