我尝试使用 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')
关于python - pandas_ml 中的 cross_validation 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34502662/