我注意到RidgeCV的cv_values_
始终处于同一度量中,无论scoring
选项如何。这是一个示例:
from sklearn.linear_model import RidgeCV
from sklearn.datasets import load_boston
boston = load_boston()
mod = RidgeCV(store_cv_values = True, scoring = 'r2')
fit = mod.fit(boston.data, boston.target)
print(fit)
print(fit.cv_values_)
mod = RidgeCV(store_cv_values = True, scoring = 'neg_mean_squared_error')
fit = mod.fit(boston.data, boston.target)
print(fit)
print(fit.cv_values_)
输出为:
RidgeCV(alphas=(0.1, 1.0, 10.0), cv=None, fit_intercept=True, gcv_mode=None,
normalize=False, scoring='r2', store_cv_values=True)
[[ 7.61705436 7.83092421 8.2298466 ]
[ 2.50029583 2.31181064 2.11665248]
[ 7.98280614 7.95286299 7.87166914]
...,
[ 5.24271689 5.50191347 5.84802692]
[ 3.7448827 4.01778493 4.40457956]
[ 0.0859419 0.37219929 0.89447484]]
RidgeCV(alphas=(0.1, 1.0, 10.0), cv=None, fit_intercept=True, gcv_mode=None,
normalize=False, scoring='neg_mean_squared_error',
store_cv_values=True)
[[ 7.61705436 7.83092421 8.2298466 ]
[ 2.50029583 2.31181064 2.11665248]
[ 7.98280614 7.95286299 7.87166914]
...,
[ 5.24271689 5.50191347 5.84802692]
[ 3.7448827 4.01778493 4.40457956]
[ 0.0859419 0.37219929 0.89447484]]
您可以看到,即使我指定了不同的scoring
,cv_values_
也是相同的。我本来可以预期cv_values_
在第一种情况下会处于r2
度量中。我想念明显的东西吗?我是Scikit-Learn的新手。这是Scikit-Learn 0.18.1在Python 3.5.2。
与ridgecv.cv_values_ docs相反,从ridgecv源代码中,看起来Scorer仅用于选择最佳的超参数(SET self.alpha_
和self.dual_coef_
属性)。
因此,应更改文档或源代码以使行为正确。在Scikit-Learn Bug Tracker中提出问题可能是个好主意。