我是机器学习的新手,在我所读的书籍和文档中,总有一个0到1之间的分数值,它代表着0%到100%之间的准确性。
在我自己的机器学习代码中,我得到了-750.880810和5154.771036之间的分数,这让我很困惑。
>>> pipe = Pipeline([("scaler", MinMaxScaler()), ("svr", SVR())])
>>> param_grid = {'svr__C':[0.1, 1, 5],
'svr__epsilon':[0.001, 0.01]}
>>> grid = GridSearchCV(estimator=pipe,
param_grid=param_grid,
cv=GroupKFold(n_splits=24)
)
>>> grid.fit(X, y, groups)
GridSearchCV(cv=GroupKFold(n_splits=24), error_score=nan,
estimator=Pipeline(memory=None,
steps=[('scaler',
MinMaxScaler(copy=True,
feature_range=(0, 1))),
('svr',
SVR(C=1.0, cache_size=200, coef0=0.0,
degree=3, epsilon=0.1,
gamma='scale', kernel='rbf',
max_iter=-1, shrinking=True,
tol=0.001, verbose=False))],
verbose=False),
iid='deprecated', n_jobs=None,
param_grid={'svr__C': [0.1, 1, 5], 'svr__epsilon': [0.001, 0.01]},
pre_dispatch='2*n_jobs', refit=True, return_train_score=False,
scoring=None, verbose=0)
>>> grid.best_score_
-750.880810有人能给我解释一下吗?
编辑:
我的输入数据是对发动机的测量。
我有12种不同的引擎故障,每一次故障都是两次=> 12x2 =24个不同的组(我也会尝试12个组)。每一组包括:
1200个样本
发布于 2020-01-16 17:29:50
精度是分类问题常用的评分方法。对于一个回归问题,它是R平方值。
对于scoring param在GridSearchCV,
如果没有
,则使用估计量的评分法。
对于SVR,默认的得分值来自RegressorMixin,即R^2。
文档:
返回预测的决定系数R^2。
系数R^2定义为(1 - u/v),其中u是残差平方和((y_true - y_pred) ** 2).sum(),v是平方之和((y_true - y_true.mean()) ** 2).sum()。
最好的分数是1.0,它可以是负的(因为模型可以任意恶化)。
一个常数模型总是预测y的期望值,而不考虑输入特性,则得到R^2分数为0.0。
因此,当您非常大/很小的值为R^2时,它听起来是有线的。
一个玩具的例子,了解得分输出。
from sklearn.preprocessing import MinMaxScaler
from sklearn.model_selection import GridSearchCV, GroupKFold
from sklearn.pipeline import Pipeline
import numpy as np
np.random.seed(0)
X, y = datasets.make_regression()
groups = np.random.randint(0, 10, len(X))
pipe = Pipeline([("scaler", MinMaxScaler()), ("svr", svm.SVR())])
parameters = {'svr__C': [ 0.1, 1, 5, 100], 'svr__epsilon': [0.001, 0.1]}
svr = svm.SVR()
clf = GridSearchCV(pipe, parameters, cv=GroupKFold(n_splits=2))
clf.fit(X, y, groups)
print(clf.best_score_)
# 0.1239707770092825我建议尝试使用不同的cv并调查这个问题。
https://stackoverflow.com/questions/59771945
复制相似问题