精确度,简单适合和交叉val

时间:2018-01-22 19:46:03

标签: python scikit-learn

我有这样简单的拟合模型:

lm = linear_model.LinearRegression()
model = lm.fit(X_train, y_train)
predictions = lm.predict(X_test)
print accuracy_score(y_test, predictions)

并且使用交叉验证我有:

from sklearn.model_selection import cross_val_score
accuracies = cross_val_score(estimator = model, X = X_train, y = y_train, cv = 7)
来自交叉验证的

如何才能获得相同的度量打印accuracy_score(y_test, predictions)?是accuracies.mean()吗?

1 个答案:

答案 0 :(得分:1)

print accuracies将在每次交叉验证中提供一系列准确性

print "Train set score :: {} ".format(accuracies.mean())将给出交叉验证的平均准确度和

print "Train set score :: {} +/-{}".format(accuracies.mean(),accuracies.std()*2)会为您提供准确性和平均偏差