Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* Small docstring change for clarity

* Added tentative changes to docs

* Update website/docs/Use-Cases/Task-Oriented-AutoML.md

Co-authored-by: Chi Wang <[email protected]>

* Update flaml/model.py

Co-authored-by: Chi Wang <[email protected]>

* Updated model.py to reflect `n_jobs = None` suggestion

* Updated tutorial to reflect `n_jobs=None` suggestion

* Update model.py

Improved string

Co-authored-by: Chi Wang <[email protected]>
Co-authored-by: Qingyun Wu <[email protected]>
  • Loading branch information
3 people authored Nov 1, 2022
1 parent 29dea3a commit 65ad650
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion flaml/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,16 @@ def search_space(cls, data_size, task, **params):


class SKLearnEstimator(BaseEstimator):
"""The base class for tuning scikit-learn estimators."""
"""
The base class for tuning scikit-learn estimators.
Subclasses can modify the function signature of ``__init__`` to
ignore the values in ``config`` that are not relevant to the constructor
of their underlying estimator. For example, some regressors in ``scikit-learn``
don't accept the ``n_jobs`` parameter contained in ``config``. For these,
one can add ``n_jobs=None,`` before ``**config`` to make sure ``config`` doesn't
contain an ``n_jobs`` key.
"""

def __init__(self, task="binary", **config):
super().__init__(task, **config)
Expand Down
2 changes: 1 addition & 1 deletion website/docs/Use-Cases/Task-Oriented-AutoML.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class MyRegularizedGreedyForest(SKLearnEstimator):
return space
```

In the constructor, we set `self.estimator_class` as `RGFClassifier` or `RGFRegressor` according to the task type. If the estimator you want to tune does not have a scikit-learn style `fit()` and `predict()` API, you can override the `fit()` and `predict()` function of `flaml.model.BaseEstimator`, like [XGBoostEstimator](../reference/model#xgboostestimator-objects).
In the constructor, we set `self.estimator_class` as `RGFClassifier` or `RGFRegressor` according to the task type. If the estimator you want to tune does not have a scikit-learn style `fit()` and `predict()` API, you can override the `fit()` and `predict()` function of `flaml.model.BaseEstimator`, like [XGBoostEstimator](../reference/model#xgboostestimator-objects). Importantly, we also add the `task="binary"` parameter in the signature of `__init__` so that it doesn't get grouped together with the `**config` kwargs that determines the parameters with which the underlying estimator (`self.estimator_class`) is constructed. If your estimator doesn't use one of the parameters that it is passed, for example some regressors in `scikit-learn` don't use the `n_jobs` parameter, it is enough to add `n_jobs=None` to the signature so that it is ignored by the `**config` dict.

2. Give the custom estimator a name and add it in AutoML. E.g.,

Expand Down

0 comments on commit 65ad650

Please sign in to comment.