| Total Complexity | 3 |
| Total Lines | 42 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | # Author: Simon Blanke |
||
| 2 | # Email: [email protected] |
||
| 3 | # License: MIT License |
||
| 4 | |||
| 5 | |||
| 6 | from sklearn.datasets import load_iris |
||
| 7 | from sklearn.model_selection import cross_val_score |
||
| 8 | from sklearn.tree import DecisionTreeClassifier |
||
| 9 | from hyperactive import Hyperactive |
||
| 10 | from hyperactive.memory import delete_model, delete_model_dataset |
||
| 11 | |||
| 12 | data = load_iris() |
||
| 13 | X, y = data.data, data.target |
||
| 14 | |||
| 15 | |||
| 16 | def model(para, X_train, y_train): |
||
| 17 | model = DecisionTreeClassifier(criterion=para["criterion"]) |
||
| 18 | scores = cross_val_score(model, X_train, y_train, cv=2) |
||
| 19 | |||
| 20 | return scores.mean() |
||
| 21 | |||
| 22 | |||
| 23 | search_config = {model: {"criterion": ["gini"]}} |
||
| 24 | |||
| 25 | |||
| 26 | def test_delete_model(): |
||
| 27 | delete_model(model) |
||
| 28 | |||
| 29 | opt = Hyperactive(X, y) |
||
| 30 | opt.search(search_config) |
||
| 31 | |||
| 32 | delete_model(model) |
||
| 33 | |||
| 34 | |||
| 35 | def test_delete_model_dataset(): |
||
| 36 | delete_model_dataset(model, X, y) |
||
| 37 | |||
| 38 | opt = Hyperactive(X, y) |
||
| 39 | opt.search(search_config) |
||
| 40 | |||
| 41 | delete_model_dataset(model, X, y) |
||
| 42 |