scikit-learn交叉验证,带有均方误差的负值 [英] scikit-learn cross validation, negative values with mean squared error

查看:977
本文介绍了scikit-learn交叉验证,带有均方误差的负值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将以下代码与大小为(952,144)的数据矩阵 X 和大小为 y 的输出向量一起使用时(952), mean_squared_error 指标返回负值,这是意外的。您有任何想法吗?

When I use the following code with Data matrix X of size (952,144) and output vector y of size (952), mean_squared_error metric returns negative values, which is unexpected. Do you have any idea?

from sklearn.svm import SVR
from sklearn import cross_validation as CV

reg = SVR(C=1., epsilon=0.1, kernel='rbf')
scores = CV.cross_val_score(reg, X, y, cv=10, scoring='mean_squared_error')

分数中的所有值都为负。 / p>

all values in scores are then negative.

推荐答案

试图解决此问题,因此请提供David和larsmans在评论部分雄辩地描述的答案:

Trying to close this out, so am providing the answer that David and larsmans have eloquently described in the comments section:

是的,这应该发生。实际的MSE只是您获得的数字的正数。

Yes, this is supposed to happen. The actual MSE is simply the positive version of the number you're getting.

统一评分API总是使得分最大化,因此将需要最小化的得分否定了以便统一评分API正常运行。因此,当返回的分数是应该最小化的分数时,它被否定;如果分数是应该最大化的分数,则返回正数。

The unified scoring API always maximizes the score, so scores which need to be minimized are negated in order for the unified scoring API to work correctly. The score that is returned is therefore negated when it is a score that should be minimized and left positive if it is a score that should be maximized.

带有管道的sklearn GridSearchCV中也对此进行了描述

这篇关于scikit-learn交叉验证,带有均方误差的负值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆