-
Notifications
You must be signed in to change notification settings - Fork 5
Closed
Labels
releasedIncluded in a releaseIncluded in a release
Description
Is your feature request related to a problem?
Finding appropriate values for hyperparameters by hand is tedious. There should be automation to try different combinations of values.
Desired solution
- For all hyperparameters of models of type
Tit should also be possible to pass aChoice[T](see feat: addChoiceclass for possible values of hyperparameter #325). Example:
# Before
class KNearestNeighbors(Classifier):
def __init__(self, number_of_neighbors: int) -> None:
...
# After
class KNearestNeighbors(Classifier):
def __init__(self, number_of_neighbors: int | Choice[int]) -> None:
...
# Usage
KNearestNeighbors(number_of_neighbors = Choice(1, 10, 100))- Adjust the getters (Getters for hyperparameters of models #260) accordingly.
- When a user tries to call
fiton a model that containsChoiceat any level (can be nested), raise an exception. Also point to the correct method (see 4.). - Add new method
fit_by_exhaustive_searchtoClassifierand subclasses with parameter:optimization_metric: The metric to use to find the best model. It should have typeClassifierMetric, which is an enum with one value for each classifier metric we have available:
The parameter should be required.class ClassifierMetric(Enum): ACCURACY = "accuracy" PRECISION = "precision RECALL = "recall" F1_SCORE = "f1_score"
- Add new method
fit_by_exhaustive_searchtoRegressorand subclasses with parameter:optimization_metric: The metric to use to find the best model. It should have typeRegressorMetric, which is an enum with one value for each regressor metric we have available:
The parameter should be required.class RegressorMetric(Enum): MEAN_SQUARED_ERROR = "mean_squared_error" MEAN_ABSOLUTE_ERROR = "mean_absolute_error"
- Both of those methods should then collect the
Choices inside of the model and its children, and for each possible setting create a model without choices, fit this, and compute the listed metric on it. It should then keep track of the best (fitted) model according to the metric and return it at the end.GridSearchCVofscikit-learncan be useful for this.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
releasedIncluded in a releaseIncluded in a release
Type
Projects
Status
✔️ Done