rgf_example.model()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 12
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 10
nop 1
dl 0
loc 12
rs 9.9
c 0
b 0
f 0
1
from sklearn.datasets import load_breast_cancer
2
from sklearn.model_selection import cross_val_score
3
from rgf.sklearn import RGFClassifier
4
5
from hyperactive import Hyperactive
6
7
data = load_breast_cancer()
8
X, y = data.data, data.target
9
10
11
def model(opt):
12
    rgf = RGFClassifier(
13
        max_leaf=opt["max_leaf"],
14
        reg_depth=opt["reg_depth"],
15
        min_samples_leaf=opt["min_samples_leaf"],
16
        algorithm="RGF_Sib",
17
        test_interval=100,
18
        verbose=False,
19
    )
20
    scores = cross_val_score(rgf, X, y, cv=3)
21
22
    return scores.mean()
23
24
25
search_space = {
26
    "max_leaf": list(range(10, 2000, 10)),
27
    "reg_depth": list(range(1, 21)),
28
    "min_samples_leaf": list(range(1, 21)),
29
}
30
31
hyper = Hyperactive()
32
hyper.add_search(model, search_space, n_iter=10)
33
hyper.run()
34