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
Read
In this order, only the parts listed
0 of 6 done
- XGBoost tree-booster parametersXGBoost parameters and sklearn estimator interface
Parameters for Tree Booster:
etadefault 0.3,max_depth6,min_child_weight1,subsample1,colsample_bytree,bylevelandbynode1,lambda1,alpha0 - XGBoost sklearn interface and early stoppingXGBoost parameters and sklearn estimator interface
Early Stopping:
XGBClassifierwithtree_methodhist,early_stopping_roundswitheval_set, best iteration used automatically for prediction - LightGBM core and control parametersLightGBM parameters
learning_rate0.1,num_leaves31,max_depth-1 for no limit with leaf-wise growth,min_data_in_leaf20,feature_fraction1.0,bagging_fraction1.0 effective only withbagging_freqabove 0,lambda_l20.0, early stopping by callback orearly_stopping_round - CatBoost common parametersCatBoost common parameters and categorical features
depth6,learning_ratechosen automatically forLogloss,MultiClassandRMSEand 0.03 otherwise,l2_leaf_reg3.0,iterations1000,SymmetricTreegrow_policy,subsample0.8 under the defaultMVSbootstrap on CPU (Bayesianfor multiclass),rsmfor columns per split,boosting_typeOrderedversusPlain,use_best_modelwitheval_set,one_hot_max_size2 - 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_iter100 replacesn_estimators,max_bins255,max_leaf_nodes31,early_stoppingautoabove 10000 rows - 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:
HistGradientBoostingRegressorwithcategorical_features=[0]: binned training with a native categorical slot
Focus on
- Learn the name map, in XGBoost, LightGBM and CatBoost order: step size is
eta,learning_rateandlearning_rate; rows aresubsample,bagging_fractionandsubsample; columns arecolsample_bytreeper tree,feature_fractionper tree andrsmper split (aliascolsample_bylevel); L2 islambda,lambda_l2andl2_leaf_reg. - Defaults that bite: XGBoost
eta0.3 against LightGBM 0.1, CatBoost 1000iterationswith a rate it picks itself for the common losses, LightGBM bagging off untilbagging_freqpasses 0, LightGBM growing leaf-wise tonum_leaves31 with no depth limit (max_depth-1), and CatBoost symmetric trees atdepth6. - Early stopping differs per library: XGBoost takes
early_stopping_roundswitheval_setand predicts from the best iteration, LightGBM takesearly_stopping_roundor theearly_stoppingcallback with a validation set, CatBoost takeseval_setwithuse_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_sizevalues (2 by default), LightGBM takes integer-codedcategorical_featurecolumns, and XGBoost takes pandascategorycolumns withenable_categorical=Trueon thehistorapproxtree method.
Common mistakes · 3
num_leaves31 withmax_depth4 cannot grow 31 leaves: depth caps the tree at 16 leaves, so set both consistently instead of copying the default.bagging_fraction0.8 alone changes nothing in LightGBM. Bagging stays off untilbagging_freqis set above 0.- Copying
n_estimators100 into CatBoost without setting the learning rate silently swaps the shrinkage regime, since CatBoost defaults to 1000iterationswith an automatic rate.
Try it yourself
Closed-book, before checking anything
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).Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.What are the default step sizes in XGBoost, LightGBM and CatBoost?Answer
XGBoost
eta0.3 and LightGBMlearning_rate0.1. CatBoost picks the rate automatically forLogloss,MultiClassandRMSE, from the iteration count, and uses 0.03 otherwise.2.Name the row-sampling parameter in each of the three libraries and any enabling switch.Answer
XGBoost
subsample; LightGBMbagging_fraction, which needsbagging_freqabove 0; CatBoostsubsample, 0.8 under the defaultMVSbootstrap on CPU, while multiclass defaults to theBayesianbootstrap.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_sizevalues, 2 by default.4.When does sklearn HGBT stop early without an explicit validation set?Answer
With
early_stoppingauto, which is the default, it reserves validation internally on data above 10000 rows. Smaller data runs the fullmax_iterunless 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 witheval_set. - LightGBM parametersLightGBM developers · reference
Read
learning_rate,num_leaves,max_depth,min_data_in_leaf,feature_fraction,bagging_fractionwithbagging_freq,lambda_l2and 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_modelandone_hot_max_sizedefaults, 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.