Model Pipeline - XGBoost
XGBoost is a smart way to build many small decision trees step-by-step. Each tree learns from the mistakes of the previous ones to make better predictions.
Jump into concepts and practice - no test required
XGBoost is a smart way to build many small decision trees step-by-step. Each tree learns from the mistakes of the previous ones to make better predictions.
Loss
0.7 |***************
0.6 |************
0.5 |*********
0.4 |******
0.3 |****
0.2 |**
0.1 |
+----------------
1 10 50 100 Epochs
| Epoch | Loss ↓ | Accuracy ↑ | Observation |
|---|---|---|---|
| 1 | 0.65 | 0.60 | Model starts learning, loss is high, accuracy low |
| 10 | 0.40 | 0.75 | Loss decreases, accuracy improves as trees add knowledge |
| 50 | 0.25 | 0.85 | Model is learning well, loss much lower, accuracy higher |
| 100 | 0.20 | 0.88 | Training converges, small improvements in loss and accuracy |
from xgboost import XGBClassifier model = XGBClassifier(use_label_encoder=False, eval_metric='logloss') X_train = [[1, 2], [3, 4]] y_train = [0, 1] model.fit(X_train, y_train) preds = model.predict([[1, 2]]) print(preds)
from xgboost import XGBClassifier model = XGBClassifier() X_train = [[1, 2], [3, 4]] y_train = [0, 1] model.fit(X_train, y_train, eval_metric='error') preds = model.predict([[5, 6]]) print(preds)