
5.8
分類器をスリムにする
109
>>>
thresh80 = threshold[idx80][0]
>>>
probs_for_good = clf.predict_proba(answer_features)[:,1]
>>>
answer_class = probs_for_good>thresh80
また、
classification_report
というモジュールを用いて、適合率と再現率の値を確認するこ
とができます。
>>>
from sklearn.metrics import classification_report
>>>
print(classification_report(y_test, clf.predict_proba [:,1]>0.63,
target_names=['not accepted', 'accepted']))
precision recall f1-score
not accepted 0.63 0.93 0.75 108
accepted 0.80 0.36 0.50 92
avg / total 0.71 0.67 0.63 200
ここでは適切な閾値を求めてきましたが、その閾値を用いることで必ず期待している適合率
と再現率を満たすとは限りません。
5.8
分類器を“スリム”にする
各特徴量が分類を行うためにどれだけ貢献しているか、ということについて見識を得ることは常に
大切なことです。ロジスティック回帰の場合、学習した結果である回帰係数(
cl