Passed
Push — master ( ef01f2...fd3757 )
by Simon
01:46 queued 10s
created

RGF.model()   A

Complexity

Conditions 1

Size

Total Lines 12
Code Lines 10

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
eloc 10
dl 12
loc 12
rs 9.9
c 0
b 0
f 0
cc 1
nop 3
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 View Code Duplication
def model(para, X, y):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
12
    rgf = RGFClassifier(
13
        max_leaf=para["max_leaf"],
14
        reg_depth=para["reg_depth"],
15
        min_samples_leaf=para["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_config = {
26
    model: {
27
        "max_leaf": range(1000, 10000, 100),
28
        "reg_depth": range(1, 21),
29
        "min_samples_leaf": range(1, 21),
30
    }
31
}
32
33
opt = Hyperactive(X, y)
34
opt.search(search_config, n_iter=5)
35