我使用 LassoCV 测试了 2 个模型,一个没有任何显式 alpha 列表,另一个带有 alpha 列表 -
Model1 = LassoCV(alphas=None, copy_X=True, cv=None, eps=0.001, fit_intercept=True,
max_iter=1000, n_alphas=100, normalize=True, precompute='auto',
tol=0.0001, verbose=False)
Model2 = LassoCV(alphas=[0.1, 0.2, 0.4, 1.0, 10.0], copy_X=True, cv=None, eps=0.001,
fit_intercept=True, max_iter=1000, n_alphas=100, normalize=True,
precompute='auto', tol=0.0001, verbose=False)
我正在使用sklearn.datasets中的糖尿病数据集以及本示例中的数据分区方案- http://scikit-learn.org/stable/auto_examples/linear_model/plot_ols.html#example-linear-model-plot-ols-py
对它们两个使用 modelX.score ,各自的错误是 -
型号1:0.47235439555084802
模型2:-0.15271790306245214
在检查 alpha 值时,我发现 Model1 的值为 0.0021734898275546505,而 Model2 的值为 10.0。
为什么它的 RMS 值为负?
这对我一点帮助都没有- negative value for "mean_squared_error"
最佳答案
LassoCV 实例的 score
方法返回 R 平方分数,该分数可以为负数。请参阅documentation :
Best possible score is 1.0, lower values are worse... Unlike most other scores, R^2 score may be negative (it need not actually be the square of a quantity R).
因此,负分仅意味着特定模型的性能非常差。
关于python - 在 scikit-learn 中使用 LassoCV.score() 时获得负分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27582627/