Search code examples
pythonscikit-learnregressioncross-validation

Predicted values of each fold in K-Fold Cross Validation in sklearn


I have performed 10-fold cross validation on a dataset that I have using python sklearn,

result = cross_val_score(best_svr, X, y, cv=10, scoring='r2')
print(result.mean())

I have been able to get the mean value of the r2 score as the final result. I want to know if there is a way to print out the predicted values for each fold( in this case 10 sets of values).


Solution

  • I believe you are looking for the cross_val_predict function.