[英]How to make the prediction from cross validation score?
I am working on building a prediction model.我正在构建一个预测模型。 I have managed to reach until getting the cross-validation scores.
我已经设法达到,直到获得交叉验证分数。 Now I have no idea how to continue.
现在我不知道如何继续。 What function should I use to make predictions using cross-validation scores?
我应该使用什么函数来使用交叉验证分数进行预测?
X = data.iloc[:,0:16]
Y = data.iloc[:,16]
validation_size = 0.20
seed = 7
X_train, X_validation, Y_train, Y_validation = model_selection.train_test_split(X, Y,
test_size=validation_size, random_state=seed)
models = [
('LR', LogisticRegression()),
('CART', DecisionTreeClassifier()),
('KNN', KNeighborsClassifier()),
('SVM', SVC())
]
results, names = [], []
for name, model in models:
seed = 32
scoring = 'accuracy'
kfold = model_selection.KFold(n_splits=10, random_state=seed)
cv_results = model_selection.cross_val_score(model, X_train, Y_train, cv=kfold, scoring=scoring)
results.append(cv_results)
names.append(name)
msg = "%s: %f (%f)" % (name, cv_results.mean(), cv_results.std())
print(msg)
Cross validation is mostly used as a more robust validation scheme to check if your model is performing well or not.交叉验证主要用作更强大的验证方案,以检查您的模型是否表现良好。 After that you can train a model with the whole dataset after being satisfied with your cross validation score or you can use.
之后,您可以在对交叉验证分数感到满意后使用整个数据集训练模型,或者您可以使用。
sklearn.model_selection.cross_val_predict
Which predicts cross validated estimates.它预测交叉验证的估计。 You can check out the documentation for more information.
您可以查看文档以获取更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.