liveBook · Manning

Cross_validate

As explained in Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI

A scikit-learn function that evaluates an estimator with cross-validation and returns scores and fit or prediction timing results.

cross_validate is a scikit-learn evaluation function for estimating how an estimator may perform on future data. It runs cross-validation, records model performance, and reports fit and prediction times, making it useful for comparing practical modeling approaches. section 4.3 section 4.3.1

A typical tabular-data workflow is:

  • Choose an evaluation metric, such as RMSE for regression or accuracy for balanced classification. section 4.3
  • Combine preprocessing and modeling in a single pipeline so each fold evaluates the complete workflow. section 4.3.1
  • Define a cross-validation strategy, such as shuffled five-fold KFold, and pass the pipeline and scorer to cross_validate. section 4.3.1
  • Inspect average and standard-deviation scores alongside fit and prediction times to judge both performance and consistency. section 4.3 section 4.3.1

Airbnb price baseline

A linear-regression pipeline can transform categorical and numeric Airbnb features, fit the model across five shuffled folds, and use RMSE to evaluate it. One reported run produced an RMSE of 33.949 with a standard deviation of 0.274, 0.06 seconds of fitting, and 0.01 seconds of prediction. This baseline can then be compared with feature-engineered alternatives. section 4.3.1

Figure 4.9 How data is distributed between train and validation across the folds of a five-fold cross-validation strategy

Use the five-fold visualization to see how training and validation data are distributed across folds. section 4.3

How Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI covers it

How deep it goes
Explains metric selection, fold strategy, score variability, and timing, but stops short of detailing cross_validate parameters.
Examples
Uses a five-fold Airbnb NYC linear-regression pipeline with categorical encoding, numeric handling, RMSE, and reported timing.
What it assumes
Assumes familiarity with estimators, preprocessing pipelines, evaluation metrics, and tabular features.
What you can do after
Apply it via scikit-learn to compare model pipelines using predictive scores, score variability, and fit or prediction times.
How it connects
Connects pipelines, ColumnTransformer, KFold, scoring metrics, linear regression, feature engineering, and concept drift.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI. The section links point to the parts of the book it draws on.