Model Pipeline - Gradient Boosting for regression
This pipeline uses gradient boosting to predict continuous values. It builds many small decision trees step-by-step, each one fixing errors from the previous trees, to improve prediction accuracy.
Jump into concepts and practice - no test required
This pipeline uses gradient boosting to predict continuous values. It builds many small decision trees step-by-step, each one fixing errors from the previous trees, to improve prediction accuracy.
Loss
0.9 |*
0.8 | *
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.85 | N/A | Initial tree reduces error but loss is still high |
| 10 | 0.45 | N/A | Loss decreases steadily as more trees are added |
| 50 | 0.20 | N/A | Model fits data better, loss much lower |
| 100 | 0.15 | N/A | Loss improvement slows, model converges |
from sklearn.ensemble import GradientBoostingRegressor
model = GradientBoostingRegressor(n_estimators=100, learning_rate=0.1) correctly imports and creates the model with parameters n_estimators and learning_rate.from sklearn.ensemble import GradientBoostingRegressor
model = GradientBoostingRegressor(n_estimators=100, learning_rate=0.1) [OK]from sklearn.ensemble import GradientBoostingRegressor import numpy as np X = np.array([[1], [2], [3], [4], [5]]) y = np.array([1.5, 3.5, 5.5, 7.5, 9.5]) model = GradientBoostingRegressor(n_estimators=10, learning_rate=0.5) model.fit(X, y) pred = model.predict(np.array([[6]])) print(round(pred[0], 1))
from sklearn.ensemble import GradientBoostingRegressor X = [[1], [2], [3]] y = [2, 4, 6] model = GradientBoostingRegressor(n_estimators=50) model.fit(X, y) print(model.predict([4]))