liveBook · Manning

XGBoost

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

A predictive model trained using XGBoost's gradient-boosted decision-tree algorithms.

XGBoost is an open-source gradient-boosting framework that builds predictive ensembles from decision trees. It is a practical starting point for many tabular-data classification and regression problems, combining strong out-of-the-box results with support for custom objectives, missing values, GPU training, and constraints on monotonicity or feature interactions. section 5.4 section 5.6

Boosting is serial: each tree learns from the errors left by earlier trees. XGBoost accelerates this process through parallel work within each tree, second-order optimization, improved split finding, and sparsity-aware splits. Its Scikit-learn API fits naturally into pipelines and model-selection workflows; pandas DataFrames and NumPy arrays are converted to the internal DMatrix format automatically. section 5.4.2 section 5.4

Use XGBoost when tabular prediction needs a capable baseline and operational flexibility:

  • Start with an XGBClassifier or XGBRegressor inside a preprocessing pipeline and assess it with cross-validation. section 5.4 section 7.2
  • Let tree splits learn a preferred direction for missing values; specify another missing-value marker when needed. Treat sparse zero entries carefully because they are handled as missing. section 6.1.2
  • Choose depthwise growth for the original level-wise strategy or lossguide for leaf-wise growth; cap leaves or depth to help avoid overfitting with lossguide. section 5.5.4
  • Test XGBoost against LightGBM and other approaches rather than assuming a universal winner. XGBoost is presented as more robust on smaller samples and more scalable with ample resources, while LightGBM can train faster on CPUs. section 6.4.1

Airbnb price prediction

For New York City listings, an XGBoost classifier predicts whether a price is above or below the market average, reaching roughly 79–81% test accuracy in 3–4 seconds in a standard Colab run. For Tokyo listings, an XGBoost regressor with a gamma objective models positive, right-skewed prices; its first cross-validated model reports R-squared of 0.693 and MAE of 7,227.435. These examples show the same tree-ensemble approach serving classification and regression after data preparation and evaluation. section 3.3.1 section 7.2.4

For faster tree construction, histogram splitting bins feature values and evaluates fewer candidate splits. In version 2.0.0 and later, tree_method="hist" is the default and reuses bins across iterations. GPU execution can be selected with device="cuda" on supported hardware. Tree structures can also be exported to JSON and inspected with plot_tree, exposing splits, thresholds, gain, and sample counts for individual trees. section 5.4.3 section 6.4.3 section 6.4.2

Figure 3.3 Files that make up the Airbnb NYC solution

Browse the shared cleanup, configuration, and training artifacts to see how an XGBoost tabular workflow differs from a Keras workflow mainly at training configuration and notebook stages. section 3.1.2

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

How deep it goes
Explains APIs, parallel training, split algorithms, missing-value routing, growth policies, GPU use, and tree-structure extraction.
Examples
Uses Airbnb New York classification and Tokyo price regression, plus histogram-split timing and exported tree paths.
What it assumes
Accepts pandas DataFrames or NumPy arrays without requiring explicit DMatrix conversion.
What you can do after
Apply it via the Scikit-learn API to train, cross-validate, evaluate, accelerate, and inspect tabular prediction models.
How it connects
Connects gradient boosting decision trees with decision trees, LightGBM, Scikit-learn pipelines, cross-validation, GPU training, and deep learning.

Also explained in

Compare how 6 books explain XGBoost →

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.