Passed
Push — master ( 7e35c2...37974c )
by Simon
03:12
created

tests.test_issue_29.test_issue_29()   A

Complexity

Conditions 1

Size

Total Lines 30
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 22
nop 0
dl 0
loc 30
rs 9.352
c 0
b 0
f 0
1
from sklearn.datasets import load_boston
2
from sklearn.ensemble import GradientBoostingRegressor
3
from sklearn.model_selection import cross_val_score
4
5
from hyperactive import Hyperactive
6
7
8
def test_issue_29():
9
    data = load_boston()
10
    X, y = data.data, data.target
11
12
    def model(para):
13
        gbr = GradientBoostingRegressor(
14
            n_estimators=para["n_estimators"],
15
            max_depth=para["max_depth"],
16
            min_samples_split=para["min_samples_split"],
17
        )
18
        scores = cross_val_score(gbr, X, y, cv=3)
19
20
        print(
21
            "Iteration:",
22
            para.optimizer.nth_iter,
23
            " Best score",
24
            para.optimizer.best_score,
25
        )
26
27
        return scores.mean()
28
29
    search_space = {
30
        "n_estimators": list(range(10, 150, 5)),
31
        "max_depth": list(range(2, 12)),
32
        "min_samples_split": list(range(2, 22)),
33
    }
34
35
    hyper = Hyperactive()
36
    hyper.add_search(model, search_space, n_iter=20)
37
    hyper.run()
38