視覺化容易與困難的範例
在這個練習中,你將透過觀察最大與最小的預測機率,視覺化出邏輯斯迴歸模型最有把握與最沒把握的範例。
手寫數字資料集已載入變數 X 與 y。show_digit 函式會接收整數索引並繪出對應影像,並在影像上方顯示一些額外資訊。
本練習屬於課程
Python 中的線性分類器
練習說明
- 在第一個空格填入模型「最有把握」的那個數字的「索引值」。
- 在第二個空格填入模型「最沒把握」的那個數字的「索引值」。
- 觀察這兩張影像:你是否同意第一張比第二張更不模糊、較不具歧義?
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
lr = LogisticRegression()
lr.fit(X,y)
# Get predicted probabilities
proba = lr.predict_proba(X)
# Sort the example indices by their maximum probability
proba_inds = np.argsort(np.max(proba,axis=1))
# Show the most confident (least ambiguous) digit
show_digit(____, lr)
# Show the least confident (most ambiguous) digit
show_digit(____, lr)