Completed
Push — master ( bd11f3...a7f87e )
by Simon
03:54
created

ray_example.gbc_()   A

Complexity

Conditions 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 9
rs 10
c 0
b 0
f 0
cc 1
nop 3
1
from sklearn.model_selection import cross_val_score
2
from sklearn.ensemble import GradientBoostingClassifier
3
from sklearn.datasets import load_breast_cancer
4
from hyperactive import Hyperactive
5
6
import ray
7
8
data = load_breast_cancer()
9
X, y = data.data, data.target
10
11
12
def gbc_(para, X, y):
13
    model = GradientBoostingClassifier(
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(model, X, y)
19
20
    return scores.mean()
21
22
23
search_config = {
24
    gbc_: {
25
        "n_estimators": range(1, 20, 1),
26
        "max_depth": range(2, 12),
27
        "min_samples_split": range(2, 12),
28
    }
29
}
30
31
32
ray.init(num_cpus=4)
33
34
opt = Hyperactive(X, y)
35
opt.search(search_config, n_jobs=4)
36