Cross validation with particular dataset lists with Python
<p>I know sklearn has nice method to get cross validation scores:</p>

<pre><code> from sklearn.model_selection import cross_val_score
 clf = svm.SVC(kernel='linear', C=1)
 scores = cross_val_score(clf, iris.data, iris.target, cv=5)
 scores      
</code></pre>

<p>I'd like to know scores with specific training and test set:</p>

<pre><code>train_list = [train1, train2, train3] # train1,2,3 is the training data sets
test_list = [test1, test2, test3] # # test1,2,3 is the test data sets
clf = svm.SVC(kernel='linear', C=1)
scores = some_nice_method(clf, train_list, test_list)
</code></pre>

<p>Is there such kind of method giving scores of particular separated data set in python?</p>

<p>This is exactly two lines of code:</p>

<pre><code>for tr, te in zip(train_list, test_list):
    svm.SVC(kernel='linear', C=1).train(X[tr, :], y[tr]).score(X[te, :], y[te])
</code></pre>

<p>See <a href="http://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html#sklearn.svm.SVC.score" rel="nofollow"><code>sklearn.svn.SVC.score</code></a>:</p>

<pre><code>score(X, y, sample_weight=None)
</code></pre>

<blockquote>
  <p>Returns the mean accuracy on the given test data and labels.</p>
</blockquote>

python machine-learning scikit-learn