2
$\begingroup$

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!!

$\endgroup$
2
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.