提升預測營收
起始模型的 RMSE 大約是 7.34。來看看能否用一次 boosting 迭代把結果變得更好。
你將再建一個線性迴歸,但這次的目標值是基礎模型的誤差,如下所示:
y_train_error = pred_train - y_train
y_test_error = pred_test - y_test
這個模型將改用 'popularity' 特徵,希望它能提供比單用 'budget' 特徵更有資訊量的模式。對應的資料已提供為 X_train_pop 與 X_test_pop。和前一題一樣,輸入特徵已替你標準化。
本練習屬於課程
Python 的 Ensemble 方法
練習說明
- 使用
X_train_pop與y_train_error,對前一步的誤差擬合一個線性迴歸模型。 - 在測試集
X_test_pop上計算預測誤差。 - 如同前一題,使用
y_test_error與pred_error計算 RMSE。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Fit a linear regression model to the previous errors
reg_error = LinearRegression()
____
# Calculate the predicted errors on the test set
pred_error = ____
# Evaluate the updated performance
rmse_error = ____
print('RMSE: {:.3f}'.format(rmse_error))