# K Fold Cross Validation in Python

I am trying to compare 2 classifying methods (SVC vs Random Forest) in order to do that I am using the cross_val_score function.

It is posible to use the same folds in both methods? In order to obtain a more accurate comparison

code: cross_val_score(SVC(gamma='auto'), x, y,cv=10) cross_val_score(RandomForestClassifier(n_estimators=40),x, y,cv=10)

Thanks!!

That's certainly what you should do for better model comparison. In sklearn, all methods that have cv as its input, you can either input a CVSplitter object or an iterable containing training and test indices for each fold which can be obtained via split method of the KFold object. This way, you'll be using the same folds.