【发布时间】:2020-11-24 07:29:08
【问题描述】:
我正在研究 Python 中的决策树回归。
遇到一个奇怪的错误:
ValueError: error_score must be the string 'raise' or a numeric value. (Hint: if using 'raise', please make sure that it has been spelled correctly.)
我的数据框大约有 330000 * 91 列。
我的代码如下所示:
# Read data
y = my_train2.iloc[:,0]
x = my_train2.iloc[:, 1:93]
(x_train, x_test, y_train, y_test) = cv.train_test_split(x, y, test_size=.20)
# Instantiate dt
dt = DecisionTreeRegressor(# max_depth = 8,
min_samples_leaf = 1,
random_state = 1)
# Fit dt to the training set
dt.fit(x_train, y_train)
下面这个块给出一个错误
from sklearn.model_selection import cross_val_score
# Compute the array containing the 10-folds CV MSEs
MSE_CV_scores = - cross_val_score(dt, x_train, y_train, cv=10,
scoring='neg_mean_squared_error',
n_jobs=-1)
# Compute the 10-folds CV RMSE
RMSE_CV = (MSE_CV_scores.mean())**(1/2)
# Print RMSE_CV
print('CV RMSE: {:.2f}'.format(RMSE_CV))
如果需要,我可以在这里打印每列的类。
谢谢!
【问题讨论】:
标签: python scikit-learn decision-tree