| Total Complexity | 1 |
| Total Lines | 26 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 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 |