There isn't a way to extract the internal cross validation splits used in the cross_val_score
, as this function does not expose any state about it. As mentioned in the documentation, either a k-fold or stratified k-fold with k=3
will be used.
However, if you need to keep track of the cross validation splits used, you can explicitly pass in the cv
argument of cross_val_score
by creating your own cross validation iterators:
from sklearn.cross_validation import KFold, cross_val_score
from sklearn.datasets import load_iris
from sklearn.svm import SVC
iris = load_iris()
kf = KFold(len(iris.target), 5, random_state=0)
clf = SVC(kernel='linear', C=1)
scores = cross_val_score(clf, iris.data, iris.target, cv=kf)
so that it uses the splits you specified exactly instead of rolling its own.