pandas_ml 中 cross_validation 的问题
issue with cross_validation in pandas_ml
我尝试使用 pandas_ml
库完成交叉验证
df = pdml.ModelFrame(features, target)
estimators = {'SVM: SVR': df.svm.SVR(),
'SVM: LinearSVR': df.svm.LinearSVR()}
for label, estimator in estimators.iteritems():
scores = df.cross_validation.cross_val_score(estimator=estimator, cv=7, scoring='accuracy')
print("Accuracy: %0.2f (+/- %0.2f) [%s]" % (scores.mean(), scores.std(), label))
但是,我遇到了意外错误
raise ValueError("{0} is not supported".format(y_type))
ValueError: continuous is not supported
这里有什么技巧吗?
这是因为 accuracy 指标仅用于对分类模型进行评分。它衡量正确预测的比例。在回归中,你想知道的不是你的预测有多少是正确的,而是你的预测离正确答案有多远——它们中的任何一个都不太可能 完全 正确所以这不是一个有意义的指标。
Regression metrics包括r2
、mean_squared_error
、mean_absolute_error
等
你可以使用类似的东西:
scores = df.cross_validation.cross_val_score(estimator=estimator, cv=7, scoring='r2')
我尝试使用 pandas_ml
库完成交叉验证
df = pdml.ModelFrame(features, target)
estimators = {'SVM: SVR': df.svm.SVR(),
'SVM: LinearSVR': df.svm.LinearSVR()}
for label, estimator in estimators.iteritems():
scores = df.cross_validation.cross_val_score(estimator=estimator, cv=7, scoring='accuracy')
print("Accuracy: %0.2f (+/- %0.2f) [%s]" % (scores.mean(), scores.std(), label))
但是,我遇到了意外错误
raise ValueError("{0} is not supported".format(y_type))
ValueError: continuous is not supported
这里有什么技巧吗?
这是因为 accuracy 指标仅用于对分类模型进行评分。它衡量正确预测的比例。在回归中,你想知道的不是你的预测有多少是正确的,而是你的预测离正确答案有多远——它们中的任何一个都不太可能 完全 正确所以这不是一个有意义的指标。
Regression metrics包括r2
、mean_squared_error
、mean_absolute_error
等
你可以使用类似的东西:
scores = df.cross_validation.cross_val_score(estimator=estimator, cv=7, scoring='r2')