test_estimators()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nop 2
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