飯店訂單資料集的商業價值計算
先前你已經看過預測訂單取消的挑戰。現在,你將使用實際的 Hotel Booking 資料集,模型會根據顧客的來源國家、從訂房到入住的時間差、所需停車位數,以及選擇的飯店來預測是否會取消訂單。
系統已為你載入參考集與分析集。以下是前兩列資料:
country lead_time parking_spaces hotel y_pred y_pred_proba is_canceled timestamp
0 FRA 120 0 City Hotel 0 0.239983 0 2016-05-01
1 ITA 120 1 City Hotel 0 0.003965 0 2016-05-01
你的任務是檢查模型的金額價值與 ROC AUC 表現。
本練習屬於課程
在 Python 中監控 Machine Learning
練習說明
- 以下界 0、上界 150,000 初始化自訂門檻值。
- 指定要監控的指標為商業價值與
roc_auc。 - 在
business_value_matrix中設定:TN為 0、FP為 -100、FN為 -200、TP為 1500。 - 將自訂門檻值套用到商業價值指標。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Custom business value thresholds
ct = ConstantThreshold(____=____, ____=____)
# Intialize the performance calculator
calc = PerformanceCalculator(problem_type='classification_binary',
y_pred_proba='y_pred_proba',
timestamp_column_name="timestamp",
y_pred='y_pred',
y_true='is_canceled',
chunk_period='m',
metrics=[____, ____],
business_value_matrix = [[____, ____],[____, ____]],
thresholds={____: ____})
calc = calc.fit(reference)
calc_res = calc.calculate(analysis)
calc_res.filter(period='analysis').plot().show()