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

LightGBM   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 21
dl 0
loc 32
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A model() 0 9 1
1
from sklearn.model_selection import cross_val_score
2
from lightgbm import LGBMRegressor
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
    lgbm = LGBMRegressor(
12
        num_leaves=para["num_leaves"],
13
        bagging_freq=para["bagging_freq"],
14
        learning_rate=para["learning_rate"],
15
    )
16
    scores = cross_val_score(lgbm, X, y, cv=3)
17
18
    return scores.mean()
19
20
21
search_config = {
22
    model: {
23
        "num_leaves": range(2, 20),
24
        "bagging_freq": range(2, 12),
25
        "learning_rate": [1e-3, 1e-2, 1e-1, 0.5, 1.0],
26
    }
27
}
28
29
30
opt = Hyperactive(X, y)
31
opt.search(search_config, n_iter=30)
32