When I was reading Sebastian's blog posts on Cross Validation a few weeks ago I also found the example of Nested cross validation on scikit-learn. At first like Daniel I thought the example was not doing what it should be doing. But after a few minutes I finally realized that it was correct. So I am for a bit more clarification.<br><br>Albert<br><div class="gmail_quote"><div dir="ltr">On Tue, 29 Nov 2016 at 02:53, Sebastian Raschka <<a href="mailto:se.raschka@gmail.com">se.raschka@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On first glance, the image shown in the image and the code example seem to do/show the same thing? Maybe it would be worth adding an explanatory figure like this to the docs to clarify?<br class="gmail_msg">
<br class="gmail_msg">
> On Nov 28, 2016, at 7:07 PM, Joel Nothman <<a href="mailto:joel.nothman@gmail.com" class="gmail_msg" target="_blank">joel.nothman@gmail.com</a>> wrote:<br class="gmail_msg">
><br class="gmail_msg">
> If that clarifies, please offer changes to the example (as a pull request) that make this clearer.<br class="gmail_msg">
><br class="gmail_msg">
> On 29 November 2016 at 11:06, Joel Nothman <<a href="mailto:joel.nothman@gmail.com" class="gmail_msg" target="_blank">joel.nothman@gmail.com</a>> wrote:<br class="gmail_msg">
> Briefly:<br class="gmail_msg">
><br class="gmail_msg">
> clf = GridSearchCV(estimator=svr, param_grid=p_grid, cv=inner_cv)<br class="gmail_msg">
> nested_score = cross_val_score(clf, X=X_iris, y=y_iris, cv=outer_cv)<br class="gmail_msg">
><br class="gmail_msg">
> Each train/test split in cross_val_score holds out test data. GridSearchCV then splits each train set into (inner-)train and validation sets. There is no leakage of test set knowledge from the outer loop into the grid search optimisation; no leakage of validation set knowledge into the SVR optimisation. The outer test data are reused as training data, but within each split are only used to measure generalisation error.<br class="gmail_msg">
><br class="gmail_msg">
> Is that clear?<br class="gmail_msg">
><br class="gmail_msg">
> On 29 November 2016 at 10:30, Daniel Homola <<a href="mailto:dani.homola@gmail.com" class="gmail_msg" target="_blank">dani.homola@gmail.com</a>> wrote:<br class="gmail_msg">
> Dear all,<br class="gmail_msg">
><br class="gmail_msg">
> I was wondering if the following example code is valid:<br class="gmail_msg">
> <a href="http://scikit-learn.org/stable/auto_examples/model_selection/plot_nested_cross_validation_iris.html" rel="noreferrer" class="gmail_msg" target="_blank">http://scikit-learn.org/stable/auto_examples/model_selection/plot_nested_cross_validation_iris.html</a><br class="gmail_msg">
><br class="gmail_msg">
> My understanding is, that the point of nested cross-validation is to prevent any data leakage from the inner grid-search/param optimization CV loop into the outer model evaluation CV loop. This could be achieved if the outer CV loop's test data is completely separated from the inner loop's CV, as shown here:<br class="gmail_msg">
> <a href="https://mlr-org.github.io/mlr-tutorial/release/html/img/nested_resampling.png" rel="noreferrer" class="gmail_msg" target="_blank">https://mlr-org.github.io/mlr-tutorial/release/html/img/nested_resampling.png</a><br class="gmail_msg">
><br class="gmail_msg">
> The code in the above example however doesn't seem to achieve this in any way.<br class="gmail_msg">
><br class="gmail_msg">
> Am I missing something here?<br class="gmail_msg">
><br class="gmail_msg">
> Thanks a lot,<br class="gmail_msg">
> dh<br class="gmail_msg">
><br class="gmail_msg">
> _______________________________________________<br class="gmail_msg">
> scikit-learn mailing list<br class="gmail_msg">
> <a href="mailto:scikit-learn@python.org" class="gmail_msg" target="_blank">scikit-learn@python.org</a><br class="gmail_msg">
> <a href="https://mail.python.org/mailman/listinfo/scikit-learn" rel="noreferrer" class="gmail_msg" target="_blank">https://mail.python.org/mailman/listinfo/scikit-learn</a><br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
> _______________________________________________<br class="gmail_msg">
> scikit-learn mailing list<br class="gmail_msg">
> <a href="mailto:scikit-learn@python.org" class="gmail_msg" target="_blank">scikit-learn@python.org</a><br class="gmail_msg">
> <a href="https://mail.python.org/mailman/listinfo/scikit-learn" rel="noreferrer" class="gmail_msg" target="_blank">https://mail.python.org/mailman/listinfo/scikit-learn</a><br class="gmail_msg">
<br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
scikit-learn mailing list<br class="gmail_msg">
<a href="mailto:scikit-learn@python.org" class="gmail_msg" target="_blank">scikit-learn@python.org</a><br class="gmail_msg">
<a href="https://mail.python.org/mailman/listinfo/scikit-learn" rel="noreferrer" class="gmail_msg" target="_blank">https://mail.python.org/mailman/listinfo/scikit-learn</a><br class="gmail_msg">
</blockquote></div>