| Total Complexity | 1 |
| Total Lines | 28 |
| 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(opt): |
||
| 11 | cbc = CatBoostClassifier( |
||
| 12 | iterations=10, depth=opt["depth"], learning_rate=opt["learning_rate"] |
||
| 13 | ) |
||
| 14 | scores = cross_val_score(cbc, X, y, cv=3) |
||
| 15 | |||
| 16 | return scores.mean() |
||
| 17 | |||
| 18 | |||
| 19 | search_space = { |
||
| 20 | "depth": list(range(2, 12)), |
||
| 21 | "learning_rate": [1e-3, 1e-2, 1e-1, 0.5, 1.0], |
||
| 22 | } |
||
| 23 | |||
| 24 | |||
| 25 | hyper = Hyperactive() |
||
| 26 | hyper.add_search(model, search_space, n_iter=10) |
||
| 27 | hyper.run() |
||
| 28 |