2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

scikit-learnのroc_auc_score関数に関する軽微なメモ

Last updated at Posted at 2021-01-17

#はじめに
大した話ではないのだがメモ。理由の掘り下げはしていない。

#環境

  • sklearn 0.22.2.post1

#scikit-learnでのrocaucの計算方法

以下のように実行する。tには正解値、yには予測値を与える

from sklearn import metrics
t = [0,1,0]
y = [1,0,0]
rocauc = metrics.roc_auc_score(t, y)
print(rocauc)

#メモ

正解値に3値以上が含まれるとエラーとなる。

from sklearn import metrics
t = [0,1,3]
y = [1,0,0]
rocauc = metrics.roc_auc_score(t, y)
print(rocauc)

multi_classの指定をすればでないらしい。

エラー内容
ValueError: multi_class must be in ('ovo', 'ovr')

正解値に1値しかない場合エラーとなる。

from sklearn import metrics
t = [0,0,0]
y = [1,0,0]
rocauc = metrics.roc_auc_score(t, y)
print(rocauc)

エラー内容
ValueError: Only one class present in y_true. ROC AUC score is not defined in that case.

予測値は必ずしも0~1の確率でなくてもよく、スコアでも構わない

どういう計算になるかは、また機会があれば。。

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?