Unit 4 of 8 · about 2 hours · explain

XGBoost, LightGBM and CatBoost configuration

Graduating from one API to the family means reading any booster config on sight. The names rhyme across libraries but the defaults do not, and that gap is where silent misconfiguration lives.

You'll be able to

  • Map depth, learning rate, row and column sampling, L2 and early stopping across XGBoost, LightGBM, CatBoost and sklearn HGBT without mixing up names.
  • State the defaults that bite and set one equivalent configuration in each library from memory.

Covers

XGBoost, LightGBM and CatBoost configuration literacy
1

Read

In this order, only the parts listed

0 of 6 done

  1. XGBoost tree-booster parametersXGBoost parameters and sklearn estimator interface

    Parameters for Tree Booster: eta default 0.3, max_depth 6, min_child_weight 1, subsample 1, colsample_bytree, bylevel and bynode 1, lambda 1, alpha 0

  2. XGBoost sklearn interface and early stoppingXGBoost parameters and sklearn estimator interface

    Early Stopping: XGBClassifier with tree_method hist, early_stopping_rounds with eval_set, best iteration used automatically for prediction

  3. LightGBM core and control parametersLightGBM parameters

    learning_rate 0.1, num_leaves 31, max_depth -1 for no limit with leaf-wise growth, min_data_in_leaf 20, feature_fraction 1.0, bagging_fraction 1.0 effective only with bagging_freq above 0, lambda_l2 0.0, early stopping by callback or early_stopping_round

  4. CatBoost common parametersCatBoost common parameters and categorical features

    depth 6, learning_rate chosen automatically for Logloss, MultiClass and RMSE and 0.03 otherwise, l2_leaf_reg 3.0, iterations 1000, SymmetricTree grow_policy, subsample 0.8 under the default MVS bootstrap on CPU (Bayesian for multiclass), rsm for columns per split, boosting_type Ordered versus Plain, use_best_model with eval_set, one_hot_max_size 2

  5. sklearn histogram gradient boosting as the local baselinescikit-learn - neighbors, SVMs, trees and ensembles

    1.11.1.1 Histogram-Based Gradient Boosting with Usage: max_iter 100 replaces n_estimators, max_bins 255, max_leaf_nodes 31, early_stopping auto above 10000 rows

  6. HoML Chapter 6: histogram boosting with native categoriesHands-On Machine Learning with Scikit-Learn and PyTorch - nonlinear classical models

    Book Chapter 6: Histogram-Based Gradient Boosting (printed pp. 214-215). Notebook 06 cells: HistGradientBoostingRegressor with categorical_features=[0]: binned training with a native categorical slot

2

Focus on

  • Learn the name map, in XGBoost, LightGBM and CatBoost order: step size is eta, learning_rate and learning_rate; rows are subsample, bagging_fraction and subsample; columns are colsample_bytree per tree, feature_fraction per tree and rsm per split (alias colsample_bylevel); L2 is lambda, lambda_l2 and l2_leaf_reg.
  • Defaults that bite: XGBoost eta 0.3 against LightGBM 0.1, CatBoost 1000 iterations with a rate it picks itself for the common losses, LightGBM bagging off until bagging_freq passes 0, LightGBM growing leaf-wise to num_leaves 31 with no depth limit (max_depth -1), and CatBoost symmetric trees at depth 6.
  • Early stopping differs per library: XGBoost takes early_stopping_rounds with eval_set and predicts from the best iteration, LightGBM takes early_stopping_round or the early_stopping callback with a validation set, CatBoost takes eval_set with use_best_model, and HGBT stops by itself only above 10000 rows.
  • Categorical handling differs too: CatBoost takes raw categories with ordered target statistics and one-hot encodes only features with at most one_hot_max_size values (2 by default), LightGBM takes integer-coded categorical_feature columns, and XGBoost takes pandas category columns with enable_categorical=True on the hist or approx tree method.
Common mistakes · 3
  • num_leaves 31 with max_depth 4 cannot grow 31 leaves: depth caps the tree at 16 leaves, so set both consistently instead of copying the default.
  • bagging_fraction 0.8 alone changes nothing in LightGBM. Bagging stays off until bagging_freq is set above 0.
  • Copying n_estimators 100 into CatBoost without setting the learning rate silently swaps the shrinkage regime, since CatBoost defaults to 1000 iterations with an automatic rate.
3

Try it yourself

Closed-book, before checking anything

Closed-book, write the 200-round learning-rate 0.05 depth-4 row and column 0.8 L2 1.0 early-stopped configuration for all four libraries, then correct every name and default against the docs. Run the HGBT version (max_iter 200, learning_rate 0.05, max_depth 4, l2_regularization 1.0, early_stopping=True, random_state 0) on make_moons(n_samples=2000, noise=0.25, random_state=0): it runs all 200 iterations because its internal validation score is still improving, and scores 0.955 on the data it was fit on (sklearn 1.9.1).
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.What are the default step sizes in XGBoost, LightGBM and CatBoost?Answer

    XGBoost eta 0.3 and LightGBM learning_rate 0.1. CatBoost picks the rate automatically for Logloss, MultiClass and RMSE, from the iteration count, and uses 0.03 otherwise.

  2. 2.Name the row-sampling parameter in each of the three libraries and any enabling switch.Answer

    XGBoost subsample; LightGBM bagging_fraction, which needs bagging_freq above 0; CatBoost subsample, 0.8 under the default MVS bootstrap on CPU, while multiclass defaults to the Bayesian bootstrap.

  3. 3.Should low-cardinality string columns be one-hot encoded for CatBoost?Answer

    No. Pass them as categorical features and let ordered target statistics handle them; CatBoost one-hot encodes only features with at most one_hot_max_size values, 2 by default.

  4. 4.When does sklearn HGBT stop early without an explicit validation set?Answer

    With early_stopping auto, which is the default, it reserves validation internally on data above 10000 rows. Smaller data runs the full max_iter unless validation is passed.

You're done when

You write all four configurations from memory with correct names, state each default you overrode, and your HGBT run matches the reference iteration count and accuracy.

Only when you can do this without notes.

Leads to

Notes

Resources · 5 for this unit, 3 more in the section
  • Hands-On Machine Learning with Scikit-Learn and PyTorch - nonlinear classical modelsAurelien Geron (O'Reilly, 2025) · primary

    Read Chapters 3, 5 and 6 and the online Appendix C notebook as the first pass through performance measures, trees, ensembles and SVMs, running notebooks 03, 05 and 06 alongside. Vary depth, estimators, learning rate, k, C and RBF width under fixed splits.

  • scikit-learn - neighbors, SVMs, trees and ensemblesscikit-learn · reference

    Check official estimator constraints, complexity, preprocessing needs, missing-value behavior and probability caveats. Do not use library calls as the mechanism implementation.

  • XGBoost parameters and sklearn estimator interfaceXGBoost developers · reference

    Read the tree-booster parameter list for eta, depth, sampling and regularization names and defaults, and the sklearn page for early stopping with eval_set.

  • LightGBM parametersLightGBM developers · reference

    Read learning_rate, num_leaves, max_depth, min_data_in_leaf, feature_fraction, bagging_fraction with bagging_freq, lambda_l2 and early stopping defaults.

  • CatBoost common parameters and categorical featuresCatBoost developers · reference

    Read iterations, learning_rate, l2_leaf_reg, depth, grow_policy, subsample, rsm, boosting_type, use_best_model and one_hot_max_size defaults, plus native categorical handling.

Also in this section

  • ISLP - tree-based methods and support vector machinesJames, Witten, Hastie, Tibshirani and Taylor · required

    Use Chapters 8 and 9 with their Python labs for the statistical account of trees, bagging, random forests, boosting and SVMs that the notebooks leave implicit, and for model-choice and feature-importance arguments.

  • Deep-ML - tree, ensemble and kernel problemsDeep-ML · support

    Use 138 Best Gini-Based Split, 20 Decision Tree Learning, 307 Bagging Classifier, 21 Pegasos Kernel SVM and 280 RBF Kernel as unit checks after the local implementation passes. Their tests were read in review; each card states what they pin, including tie and update-order conventions.

  • Probabilistic Machine Learning, Chapter 16: exemplar-based methodsKevin Murphy · support

    Read Sections 16.1 to 16.1.3 for the KNN decision rule, the curse of dimensionality with the growing-hypercube example, and the speed section on k-d trees, hashing and approximate search.