scikit-learn / scikit-learn/scikit-learn

Early Stopping for GridSearchCV, RandomizedSearchCV

Open
#25,187 5 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

module:model_selection New Feature
Dominant language
Python
Stars
67.3k
Forks
27.4k
Avg merge
1d 15h
Merged PRs (30d)
58

Description

Describe the workflow you want to enable
  • I have a custom model implementing the BaseEstimator, for which I am using scikit-learn's hyperparameter searches.
  • I am running an exhaustive grid search, all possible parameters for my model.
  • If one parameter setting gives a sufficiently high accuracy (e.g. F1 = 1.0), I wish to stop the grid search and free the compute for other runs.
Describe your proposed solution

GridSearchCV, RandomizedSearchCV, and others should have an early stopping criteria. I should be able to specify a threshold accuracy, such that when the value returned by the scoring function passes this threshold, other jobs are stopped.

Describe alternatives you've considered, if relevant

No response

Additional context

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in sklearn/model_selection/_search.py around the parallel search code at line 822, focusing on how GridSearchCV and RandomizedSearchCV collect results. Review the linked joblib discussion before deciding how scores should be checked as jobs return. Done means an agreed early-stopping threshold can stop remaining search work without breaking parallel execution.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, scikit-learn
Domain
machine-learning
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.