彙總並對機率設門檻
在使用集成方法時,有許多彙總方式可選。其中最常見的是算術平均與中位數。
你幾乎在任何情況下都可以使用平均數;而中位數則適合在 estimators 中至少包含 3 個(含)以上分類器時再考慮。
請使用算術平均來從 apple 資料集中篩出離群值。probability_scores 與 apple 已從前一個練習提供。NumPy 也已載入。
本練習屬於課程
Python 中的異常偵測
練習說明
- 計算
probability_scores沿列的平均值。 - 建立布林遮罩,當機率大於 0.75 時回傳 True。
- 使用
is_outlier遮罩來篩選離群值。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Find the mean across rows
mean_probs = ____
# Create a boolean mask that uses a 75% threshold
is_outlier = ____
# Use the mask to filter outliers from apple
outliers = ____
print(len(outliers))