What does KFold in python exactly do?
<p>I am looking at this tutorial: <a href="https://www.dataquest.io/mission/74/getting-started-with-kaggle" rel="noreferrer">https://www.dataquest.io/mission/74/getting-started-with-kaggle</a></p>

<p>I got to part 9, making predictions. In there there is some data in a dataframe called titanic, which is then divided up in folds using:</p>

<pre><code># Generate cross validation folds for the titanic dataset.  It return the row indices corresponding to train and test.
# We set random_state to ensure we get the same splits every time we run this.
kf = KFold(titanic.shape[0], n_folds=3, random_state=1)
</code></pre>

<p>I am not sure what is it exactly doing and what kind of object kf is. I tried reading the documentation but it did not help much. Also, there are three folds (n_folds=3), why is it later only accessing train and test (and how do I know they are called train and test) in this line?</p>

<pre><code>for train, test in kf:
</code></pre>