# XGBoost

> A fast, free tool for boosted trees. Often the best pick for table data.

**Field:** Artificial Intelligence  
**Category:** Machine Learning  
**Also known as:** Extreme Gradient Boosting, XGBoost Library

## Think of it like

It is like a well-tuned race bike. Same idea as a bike, built to go fast.

## Definition

XGBoost is a free code library that builds gradient-boosted trees fast. You give it a table of data, and it trains a chain of small trees. Each tree fixes the errors of the ones before. It has guards against overfitting built in, and it can run on many machines. It works from Python, R and other languages. For table data, it is often the model to beat.

## Example

Jack predicts which customers will cancel. He feeds 20 columns of account data to XGBoost, and it beats his neural network.

## Example code

```python
import xgboost as xgb
model = xgb.XGBClassifier(n_estimators=200, max_depth=4)
model.fit(X_train, y_train)
model.predict(X_test[:1])
# array([1])
```

Two hundred small trees, trained in a chain, then asked about one new row.

## Why it matters

It gives top results on spreadsheet-style data with little effort. Many real systems still run on it.

## Common mistake

Reaching for deep learning first on table data. A boosted tree library like this often wins.

## Three principles

- **Gradient boosting.** A chain of trees fixing errors.
- **Built for speed.** Uses many cores and machines.
- **Table data.** Rows and columns, not photos.

## Related terms

- [Gradient Boosting](https://learn.benibix.com/term/ai/gradient-boosting)
- [Decision Tree](https://learn.benibix.com/term/ai/decision-tree)
- [Ensemble Learning](https://learn.benibix.com/term/ai/ensemble-learning)
- [Random Forest](https://learn.benibix.com/term/ai/random-forest)
- [scikit-learn](https://learn.benibix.com/term/ai/scikit-learn)

## Taught in

- [Decision Trees and Forests](https://learn.benibix.com/learn/ai-machine-learning/decision-trees-and-forests): Machine Learning, 10/18

![Top row, random forest: three trees side by side each give a vote, and the most common vote wins. Bottom row, gradient boosting: three trees in a chain, each one fixing the errors left by the one before.](https://learn.benibix.com/diagrams/ml-forest-boosting.svg)

---

Source: https://learn.benibix.com/term/ai/xgboost
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
