Anakin Skywalker
Anakin Skywalker

Reputation: 2520

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.)

I am working on decision tree regression in Python.

Got a weird error:

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.)

My data frame has 330000 * 91 columns approximately.

My code looks like this:

# 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)

This chunk below give an error

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))

I can print here the class of each column if necessary.

Thanks!

Upvotes: 1

Views: 2943

Answers (1)

Sepideh Mazrouee
Sepideh Mazrouee

Reputation: 11

Could be related the version of your scikit-learn. I guess this error appears for 0.22. Maybe... downgrade it to 0.21 and try again

Upvotes: 1

Related Questions