MulaiMulai sekarang secara gratis

Your first AdaBoost model

In the previous lesson you built models to predict the log-revenue of movies. You started with a simple linear regression and got an RMSE of 7.34. Then, you tried to improve it with an iteration of boosting, getting to a lower RMSE of 7.28.

In this exercise, you'll build your first AdaBoost model - an AdaBoostRegressor - in an attempt to improve performance even further.

The movies dataset has been loaded and split into train and test sets. Here you'll be using the 'budget' and 'popularity' features, which were already standardized for you using StandardScaler() from sklearn.preprocessing module.

Latihan ini adalah bagian dari kursus

Ensemble Methods in Python

Lihat Kursus

Petunjuk latihan

  • Instantiate the default linear regression model.
  • Build and fit an AdaBoostRegressor, using the linear regression as the base model and 12 estimators.
  • Calculate the predictions on the test set.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Instantiate the default linear regression model
reg_lm = ____

# Build and fit an AdaBoost regressor
reg_ada = ____(____, ____, random_state=500)
reg_ada.fit(X_train, y_train)

# Calculate the predictions on the test set
pred = ____

# Evaluate the performance using the RMSE
rmse = np.sqrt(mean_squared_error(y_test, pred))
print('RMSE: {:.3f}'.format(rmse))
Edit dan Jalankan Kode