開始使用免費開始

使用 CatBoost 預測電影營收

movies 資料集來為本章的 boosting 作結吧!在這個練習中,你將建立一個 CatBoostRegressor 來預測對數營收。記得目前表現最好的模型是 AdaBoost,RMSE 為 5.15

CatBoost 能贏過 AdaBoost 嗎?我們會盡量使用相近的參數來做公平比較。

回顧一下,我們目前使用的特徵為:'budget''popularity''runtime''vote_average''vote_count'catboost 已經以 cb 匯入。

注意:千萬別使用分類器,否則你的工作階段可能會逾時!

本練習屬於課程

Python 的 Ensemble 方法

檢視課程

練習說明

  • 建立並訓練一個 CatBoostRegressor,使用 100 個 estimators、學習率 0.1,以及最大深度 3
  • 計算測試集的預測值,並列印 RMSE。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

import catboost as cb

# Build and fit a CatBoost regressor
reg_cat = ____.____(____, ____, ____, random_state=500)
____

# Calculate the predictions on the test set
pred = ____

# Evaluate the performance using the RMSE
rmse_cat = np.sqrt(mean_squared_error(y_test, pred))
print('RMSE (CatBoost): {:.3f}'.format(rmse_cat))
編輯並執行程式碼