モデル評価:不均衡な分類モデル

Pythonで学ぶMachine Learning面接対策

Lisa Stuart

Data Scientist

クラス不均衡

  • 目標変数はカテゴリ
    • 各クラスの件数は概ね同程度が理想
    • 大きく偏ると結果が誤解を招く

不均衡 vs 均衡クラス

Pythonで学ぶMachine Learning面接対策

混同行列

混同行列

1 https://scaryscientist.blogspot.com/2016/03/confusion-matrix.html
Pythonで学ぶMachine Learning面接対策

評価指標

評価指標

1 https://scaryscientist.blogspot.com/2016/03/confusion-matrix.html
Pythonで学ぶMachine Learning面接対策

行列から得る指標

評価指標

1 https://scaryscientist.blogspot.com/2016/03/confusion-matrix.html
Pythonで学ぶMachine Learning面接対策

再サンプリング手法

  • 少数クラスをオーバーサンプリング
  • 多数クラスをアンダーサンプリング
  • 注意:再サンプリングはテスト・訓練分割の前に行う

再サンプリング手法

1 https://www.svds.com/learning-imbalanced-classes/
Pythonで学ぶMachine Learning面接対策

関数

関数 戻り値
sklearn.linear_model.LogisticRegression ロジスティック回帰
sklearn.metrics.confusion_matrix(y_test,y_pred) 混同行列
sklearn.metrics.precision_score(y_test,y_pred) 適合率(precision)
sklearn.metrics.recall_score(y_test,y_pred) 再現率(recall)
sklearn.metrics.f1_score(y_test,y_pred) F1 スコア
sklearn.utils.resample(deny, n_samples=len(approve)) 再サンプリング
Pythonで学ぶMachine Learning面接対策

演習に進みましょう!

Pythonで学ぶMachine Learning面接対策

Preparing Video For Download...