How it works...
In Step 2, we defined the cross-validation scheme. As there is no inherent order in the data, we used shuffling and specified the random state for reproducibility. Stratification ensured that each fold received a similar ratio of classes in the target variable.
In Step 3, we evaluated the Pipeline created in the Implementing scikit-learn's pipelines recipe using cross_val_score. We passed the estimator (the entire Pipeline), the training data, and the cross-validation scheme as arguments to the function. We could have also provided a number to the cv argument (the default is 5)—if it had been a classification problem, it would have automatically applied the stratified k-fold cross-validation. However, by providing a custom ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access