Complete the code to import the GradientBoostingRegressor from scikit-learn.
from sklearn.ensemble import [1]
The GradientBoostingRegressor is the correct class to import for gradient boosting regression models in scikit-learn.
Complete the code to create a Gradient Boosting regressor with 100 trees.
model = GradientBoostingRegressor(n_estimators=[1])Setting n_estimators=100 creates a model with 100 boosting stages (trees), which is a common default.
Fix the error in the code to fit the model on training data X_train and y_train.
model.[1](X_train, y_train)The fit method trains the model on the given data. Using predict or transform here is incorrect.
Fill both blanks to compute the mean squared error between true and predicted values.
from sklearn.metrics import [1] error = [2](y_true, y_pred)
The mean_squared_error function computes the average squared difference between true and predicted values, which is a common regression metric.
Fill all three blanks to create a Gradient Boosting regressor with learning rate 0.1, max depth 3, and fit it on data.
model = GradientBoostingRegressor(learning_rate=[1], max_depth=[2]) model.[3](X_train, y_train)
Setting learning_rate=0.1 controls the step size at each boosting iteration. max_depth=3 limits tree depth to avoid overfitting. The fit method trains the model.