| @@ 19-28 (lines=10) @@ | ||
| 16 | y_pd = pd.DataFrame(y_np, columns=["y1"]) |
|
| 17 | ||
| 18 | ||
| 19 | def model(para, X_train, y_train): |
|
| 20 | model = DecisionTreeClassifier( |
|
| 21 | criterion=para["criterion"], |
|
| 22 | max_depth=para["max_depth"], |
|
| 23 | min_samples_split=para["min_samples_split"], |
|
| 24 | min_samples_leaf=para["min_samples_leaf"], |
|
| 25 | ) |
|
| 26 | scores = cross_val_score(model, X_train, y_train, cv=3) |
|
| 27 | ||
| 28 | return scores.mean(), model |
|
| 29 | ||
| 30 | ||
| 31 | search_config = { |
|
| @@ 17-26 (lines=10) @@ | ||
| 14 | def test_sklearn(): |
|
| 15 | from sklearn.tree import DecisionTreeClassifier |
|
| 16 | ||
| 17 | def model(para, X_train, y_train): |
|
| 18 | model = DecisionTreeClassifier( |
|
| 19 | criterion=para["criterion"], |
|
| 20 | max_depth=para["max_depth"], |
|
| 21 | min_samples_split=para["min_samples_split"], |
|
| 22 | min_samples_leaf=para["min_samples_leaf"], |
|
| 23 | ) |
|
| 24 | scores = cross_val_score(model, X_train, y_train, cv=3) |
|
| 25 | ||
| 26 | return scores.mean(), model |
|
| 27 | ||
| 28 | search_config = { |
|
| 29 | model: { |
|
| @@ 15-24 (lines=10) @@ | ||
| 12 | y = data.target |
|
| 13 | ||
| 14 | ||
| 15 | def model(para, X_train, y_train): |
|
| 16 | model = DecisionTreeClassifier( |
|
| 17 | criterion=para["criterion"], |
|
| 18 | max_depth=para["max_depth"], |
|
| 19 | min_samples_split=para["min_samples_split"], |
|
| 20 | min_samples_leaf=para["min_samples_leaf"], |
|
| 21 | ) |
|
| 22 | scores = cross_val_score(model, X_train, y_train, cv=3) |
|
| 23 | ||
| 24 | return scores.mean(), model |
|
| 25 | ||
| 26 | ||
| 27 | search_config = { |
|
| @@ 15-24 (lines=10) @@ | ||
| 12 | y = data.target |
|
| 13 | ||
| 14 | ||
| 15 | def model(para, X_train, y_train): |
|
| 16 | model = DecisionTreeClassifier( |
|
| 17 | criterion=para["criterion"], |
|
| 18 | max_depth=para["max_depth"], |
|
| 19 | min_samples_split=para["min_samples_split"], |
|
| 20 | min_samples_leaf=para["min_samples_leaf"], |
|
| 21 | ) |
|
| 22 | scores = cross_val_score(model, X_train, y_train, cv=3) |
|
| 23 | ||
| 24 | return scores.mean(), model |
|
| 25 | ||
| 26 | ||
| 27 | search_config = { |
|