| Total Complexity | 1 |
| Total Lines | 26 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | """Test module for sklearn parametrize_with_checks integration.""" |
||
| 2 | |||
| 3 | from sklearn import svm |
||
| 4 | from sklearn.model_selection import KFold |
||
| 5 | from sklearn.utils.estimator_checks import parametrize_with_checks |
||
| 6 | |||
| 7 | from hyperactive.integrations import HyperactiveSearchCV, OptCV |
||
| 8 | from hyperactive.opt import GridSearchSk as GridSearch |
||
| 9 | from hyperactive.optimizers import RandomSearchOptimizer |
||
| 10 | |||
| 11 | svc = svm.SVC() |
||
| 12 | parameters = {"kernel": ["linear", "rbf"], "C": [1, 10]} |
||
| 13 | opt = RandomSearchOptimizer() |
||
| 14 | hyperactivecv = HyperactiveSearchCV(svc, parameters, opt) |
||
| 15 | |||
| 16 | cv = KFold(n_splits=2, shuffle=True, random_state=42) |
||
| 17 | optcv = OptCV(estimator=svc, optimizer=GridSearch(param_grid=parameters), cv=cv) |
||
| 18 | |||
| 19 | ESTIMATORS = [hyperactivecv, optcv] |
||
| 20 | |||
| 21 | |||
| 22 | @parametrize_with_checks(ESTIMATORS) |
||
| 23 | def test_estimators(estimator, check): |
||
| 24 | """Test estimators with sklearn estimator checks.""" |
||
| 25 | check(estimator) |
||
| 26 |