Gradient Boosting builds a strong model by combining many weak models. What is the main way it improves predictions at each step?
Think about how the model learns from mistakes made before.
Gradient Boosting fits each new model to the errors (residuals) of the combined previous models, improving predictions step-by-step.
Consider this Python snippet training a Gradient Boosting Regressor on a simple dataset. What is the printed training loss after 3 iterations?
from sklearn.ensemble import GradientBoostingRegressor from sklearn.metrics import mean_squared_error import numpy as np X = np.array([[1], [2], [3], [4], [5]]) y = np.array([1.5, 3.5, 3.0, 5.0, 7.5]) model = GradientBoostingRegressor(n_estimators=3, learning_rate=1.0, max_depth=1, random_state=42) model.fit(X, y) pred = model.predict(X) loss = mean_squared_error(y, pred) print(round(loss, 2))
Check how well the model fits the small dataset after 3 boosting steps.
The model reduces error progressively; after 3 estimators, the mean squared error is about 0.12.
You want to use Gradient Boosting for a classification task with many categorical features. Which base learner is most suitable?
Think about what base learners are commonly used in Gradient Boosting and handle categorical data well.
Decision trees are the standard base learners in Gradient Boosting and handle categorical features effectively.
What happens if you set the learning rate too high in a Gradient Boosting model?
Consider how a large step size affects the model updates.
A high learning rate causes large updates that can lead to overfitting and unstable training.
After training a Gradient Boosting model, you get these feature importances: {'age': 0.6, 'income': 0.3, 'gender': 0.1}. What does this mean?
Think about what feature importance measures in Gradient Boosting.
Feature importance shows how much each feature helps reduce error; higher means more contribution.