Completed
Push — master ( b24ce1...799a98 )
by Simon
04:22 queued 02:04
created

catboost_example   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 16
dl 0
loc 26
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A model() 0 7 1
1
from sklearn.model_selection import cross_val_score
2
from catboost import CatBoostClassifier
3
from sklearn.datasets import load_breast_cancer
4
from hyperactive import Hyperactive
5
6
data = load_breast_cancer()
7
X, y = data.data, data.target
8
9
10
def model(para, X, y):
11
    model = CatBoostClassifier(
12
        iterations=10, depth=para["depth"], learning_rate=para["learning_rate"]
13
    )
14
    scores = cross_val_score(model, X, y, cv=3)
15
16
    return scores.mean()
17
18
19
search_config = {
20
    model: {"depth": range(2, 22), "learning_rate": [1e-3, 1e-2, 1e-1, 0.5, 1.0]}
21
}
22
23
24
opt = Hyperactive(search_config, n_iter=5)
25
opt.fit(X, y)
26