Skip to content

fix(earlystopping): use the median of Trial averages in medianstop - #2747

Open
parth-patel010 wants to merge 1 commit into
kubeflow:masterfrom
parth-patel010:fix/medianstop-use-median
Open

parth-patel010 wants to merge 1 commit into
kubeflow:masterfrom
parth-patel010:fix/medianstop-use-median

Conversation

@parth-patel010

Copy link
Copy Markdown

What this PR does / why we need it:

The medianstop early stopping service was computing the mean of the completed Trials' running averages and using that as the "median" threshold. With one outlier Trial the threshold moves a lot, so Trials that are better than the median can get early stopped (or bad ones keep running). For averages 0.1, 0.2 and 0.9 on a MAXIMIZE objective, the rule was accuracy < 0.4 instead of accuracy < 0.2.

This switches the calculation to statistics.median, which matches the docs ("the median value of the running averages of all completed Trials") and the original median stopping rule.

I also added a unit test that mocks the DB manager's GetObservationLog responses for three succeeded Trials and checks the returned rule (name, comparison, start_step and value). The existing GetEarlyStoppingRules test only checks the status code. The new test fails on master (0.4 != 0.2) and passes with this change. pytest test/unit/v1beta1/earlystopping: 3 passed. pre-commit (isort, black, flake8) is clean on the changed files.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #2746

Checklist:

  • Docs included if any changes are user facing (no docs change needed, the docs already describe the median)

The medianstop service averaged the completed Trials' running averages
instead of taking their median, so a single outlier Trial could move the
early stopping threshold and stop Trials that are better than the median.

Use statistics.median and add a unit test that mocks the DB manager logs.

Signed-off-by: parth-patel010 <parthp12321@gmail.com>
@google-oss-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign andreyvelich for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

medianstop early stopping uses the mean of Trial averages instead of the median

1 participant