简体   繁体   English

如何根据交叉验证分数进行预测?

[英]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.

相关问题 如何在sklearn中的交叉验证中获得预测结果 - How to get the prediction results in cross validation in sklearn 如何在scikit-learn中使用交叉验证来获得预测概率 - How to get the prediction probabilities using cross validation in scikit-learn 交叉验证预测因子得分相同 - Cross validation predictor score the same python 中的 OOB 分数和交叉验证 - OOB score and cross validation in python 如何计算留一法交叉验证的敏感性得分? - How to calculate sensitivity score of Leave One Out Cross Validation? 我如何抑制张量流显示每个类的检测分数以使边界框预测可读 - How do I suppress tensorflow from showing the detection score for each class to make my bounding box prediction readable 交叉验证:来自scikit-learn参数的cross_val_score函数 - Cross validation: cross_val_score function from scikit-learn arguments Sklearn - 使用交叉验证进行价格预测 - Sklearn - price prediction using cross validation 如何获得在sklearn.cross_validation.cross_val_score中内部分区的折叠本身? - How to get the folds themselves that are partitioned internally in sklearn.cross_validation.cross_val_score? 对于交叉验证中的预定义得分对象,是否需要在评分参数中使用make_scorer? - Is it necesary to use make_scorer in the scoring argument for pre-defined score object in cross-validation?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM