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

RGF   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 35
Duplicated Lines 34.29 %

Importance

Changes 0
Metric Value
wmc 1
eloc 24
dl 12
loc 35
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A model() 12 12 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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