autogridsearch_wrapper#
- pybear.model_selection.autogridsearch_wrapper(GridSearchParent)#
Wrap a scikit-learn, pybear, or dask_ml GridSearchCV class with a class that overwrites the fit method of that GridSearchCV.
The superseding fit method automates multiple calls to the parent fit method with progressively more precise search grids based on previous search results. See the scikit, pybear, and dask_ml documentation for more information about the available GridSearchCV modules.
- Parameters:
- GridSearchParentobject
Sci-kit, pybear, or dask_ml GridSearchCV CLASS, not instance.
- Returns:
- AutoGridSearchobject
Wrapped GridSearchCV class. The original fit method is replaced with a new fit method that can make multiple calls to the original fit method with increasingly precise search grids.
See also
sklearn.model_selection.GridSearchCVpybear.model_selection.GSTCVpybear-dask.model_selection.GSTCVDask
Examples
>>> from pybear.model_selection import autogridsearch_wrapper >>> from sklearn.model_selection import GridSearchCV as sk_GSCV >>> from sklearn.linear_model import Ridge as sk_RR >>> from sklearn.datasets import make_regression >>> >>> AGSCV = autogridsearch_wrapper(sk_GSCV) >>> _params = { ... 'alpha': [[0, 0.1, 0.2], 3, 'soft_float'], ... 'fit_intercept': [[True, False], [2, 1, 1], 'fixed_bool'] ... } >>> agscv = AGSCV(estimator=sk_RR(), params=_params, total_passes=3) >>> X, y = make_regression(n_samples=20, n_features=2, n_informative=2) >>> agscv.fit(X, y) AutoGridSearch( estimator=Ridge(), params={ 'alpha': [[0.0, 0.1, 0.2], [3, 3, 3], 'soft_float'], 'fit_intercept': [[True, False], [2, 1, 1], 'fixed_bool'] }, total_passes=3 ) >>> print(agscv.RESULTS_[1]) {'alpha': 0.025, 'fit_intercept': True}