| Total Complexity | 1 | 
| Total Lines | 35 | 
| Duplicated Lines | 34.29 % | 
| Changes | 0 | ||
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):  | 
            |
| 
                                                                                                    
                        
                         | 
                |||
| 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 |