简体   繁体   English

同时调用SKLearn的cross_val_score和cross_val_predict?

[英]Call SKLearn's cross_val_score and cross_val_predict at the same time?

I am running a nested-cross validation with cross_val_score by passing a GridSearchCV object to it.我通过将GridSearchCV对象传递给cross_val_score来运行嵌套交叉验证。 Then I follow up with cross_val_predict to get model predictions for graphing.然后我跟进cross_val_predict以获得用于绘图的模型预测。 Like this:像这样:

gs = GridSearchCV(mymodel, myparams)
score = cross_val_score(gridsearch, X_train, y_train)
prediction = cross_val_predict(gs, X_train, y_train)

This seems computationally redundant;这在计算上似乎是多余的; is there a way to get the cross-validated predictions from cross_val_score , or do I need to manually iterate through the folds of a CV object to do this in one step?有没有办法从cross_val_score获得交叉验证的预测,或者我是否需要手动遍历 CV 对象的折叠以一步完成?

From what I am seeing in the documentation it appears that cross_val_score and cross_val_predict obtain their values by different processes and it is not recommended for the two to be combined.从我在文档中看到的情况来看, cross_val_scorecross_val_predict似乎是通过不同的过程获取它们的值,不建议将两者结合使用。

https://scikit-learn.org/stable/modules/cross_validation.html#obtaining-predictions-by-cross-validation https://scikit-learn.org/stable/modules/cross_validation.html#obtaining-predictions-by-cross-validation

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 cross_val_score 和 cross_val_predict 的区别 - Difference between cross_val_score and cross_val_predict 机器学习 cross_val_score 与 cross_val_predict - MachineLearning cross_val_score vs cross_val_predict 是否可以在cross_val_score 中的cross_val_predict 中使用相同的k 折? - Is it possible to use the same k-folds in cross_val_predict that are in cross_val_score? 用cross_val_score计算的指标与从cross_val_predict开始计算的相同指标有何不同? - How a metric computed with cross_val_score can differ from the same metric computed starting from cross_val_predict? 使用 cross_val_predict 与 cross_val_score 时,scikit-learn 分数不同 - scikit-learn scores are different when using cross_val_predict vs cross_val_score ROC AUC 值与 cross_val_score 和 cross_val_predict 的差异 - Differences in ROC AUC values with cross_val_score and cross_val_predict cross_val_score,cross_val_predict和cross_val_validate如何进行培训,测试和验证? - How does cross_val_score, cross_val_predict, and cross_val_validate take care of training, testing and validation? SKLearn中的Cross_val_predict-需要一个数组,但是 - Cross_val_predict in SKLearn - expected an array but 如何使用cross_val_score()Sklearn? - How to use cross_val_score() Sklearn? 如何使用sklearn的cross_val_score()标准化数据 - How to standardize data with sklearn's cross_val_score()
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM