我有安装树参数和stratifiedkfold。现在,将GridSearchCV与DecisioonTreeClassifier一起使用并运行.fit方法。但是我得到一个KeyError:无
使用Jupyter笔记本并且之前运行过GridSearchCV且没有错误,不确定为什么此数据帧失败了
tree = DecisionTreeClassifier(np.random.seed(17), class_weight = 'balanced')
max_depth_values = [5, 6, 7, 8, 9]
max_features_values = [4, 5, 6, 7]
tree_params = {'max_depth': max_depth_values, 'max_features': max_features_values}
skf = StratifiedKFold(n_splits=5, shuffle=True, random_state = np.random.seed(17))
tree_grid = GridSearchCV(tree, tree_params, cv=skf, scoring='roc_auc')
tree_grid.fit(X, y)
The code fails with the below error and I am not sure whats causing this
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-45-3ea31d6abb73> in <module>
3 tree_grid = GridSearchCV(tree, tree_params, cv=skf, scoring='roc_auc')
4
----> 5 tree_grid.fit(X, y)
KeyError: None