Reputation: 99
I'm working on a Multiple Linear Regression problem and I'm evaluating its performance by R^2, MAE and cross_val_score(). I have a feature_set of size (1565,334) and y1 of size(1565,1). Here is my code:
mreg = LinearRegression()
mreg.fit(x_train,y_train)
mlr_y_predict = mreg.predict(x_test)
from sklearn.model_selection import cross_val_score
from sklearn import metrics
mae_mlr = metrics.mean_absolute_error(y_test, mlr_y_predict)
r2_mlr = metrics.r2_score(y_test,mlr_y_predict)
cvs = cross_val_score(mreg,feature_set,y1,cv=10)
print("Accuracy: %0.2f (+/- %0.2f)" % (cvs.mean(), cvs.std() * 2))
Result:
R^2: 0.9965384981365643
MAE: 3.479652627390258
Accuracy: -71566695397566744.00 (+/- 352467332828473856.00)
Why am I getting such a negative value for cross_val_score()? Does it mean the model is not good or what?
Upvotes: 0
Views: 336
Reputation: 49
The unified scoring API also maximizes the performance, thereby negating scores that need to be minimized in order for the unified scoring API to function properly. Therefore, the score returned is negated when it is a score that should be minimized and left positive if it is a score that should be maximized.
Upvotes: 1