Machine Learning & AI

xgboost

For years, this was the not-so-secret weapon behind nearly every winning data science competition entry.

Install it: pip install xgboost

What does it do?

XGBoost builds predictions by stacking together hundreds of small, imperfect decision trees, where each new tree focuses on correcting the mistakes of the ones before it. It’s especially good with the kind of data that lives in spreadsheets and databases, rows and columns of numbers, rather than images or text. The result is often startlingly accurate predictions with relatively little tuning. It’s the reason gradient boosting went from an obscure statistics term to something startups list as a core technology.

See it in action

This code loads a sample dataset of flowers, trains a prediction model to tell the flower types apart, and then has it guess the type of a few flowers.

import xgboost as xgb
from sklearn.datasets import load_iris

X, y = load_iris(return_X_y=True)
model = xgb.XGBClassifier()
model.fit(X, y)
print(model.predict(X[:5]))

Why would a non-developer care?

If a company predicts which customers will cancel a subscription, which loan applicants might default, or which ad you’re most likely to click, there’s a good chance a gradient boosting model like this is quietly doing that math. It matters because it consistently delivers strong, practical accuracy on the everyday tabular data businesses actually have, not the exotic images or text that get more headlines.

Real-world examples

XGBoost became famous for dominating Kaggle machine learning competitions throughout the mid-2010s, often appearing in the winning solution regardless of the problem. It’s widely used in finance for credit risk scoring and in e-commerce for churn and recommendation models. Without tools like it, teams would rely on slower, less accurate traditional statistical models for these everyday business predictions.

Who uses it

Data scientists working with structured business data in finance, insurance, and e-commerce, plus competitive machine learning practitioners.

How it compares to alternatives

Its closest rivals are LightGBM, built by Microsoft for speed on very large datasets, and CatBoost, built by Yandex for handling categorical data more gracefully. All three implement the same core idea, gradient boosted trees, but differ in speed, memory use, and how much manual tuning they need.

Fun fact

XGBoost stands for Extreme Gradient Boosting and was originally created by Tianqi Chen as a research project; its dominance in Kaggle competitions around 2015-2016 is widely credited with popularizing gradient boosting as a mainstream technique.

New to Python and want to actually try libraries like this yourself?

Find a beginner-friendly course

Related libraries