対角線を横切るROC曲線


12

現在、バイナリ分類器を実行しています。ROC曲線をプロットすると、最初は良好なリフトが得られ、方向が変わり、対角線を横切り、もちろん元に戻り、曲線がSのような傾斜した形状になります。

この効果の解釈/説明は何ですか?

ありがとう


1
ROC曲線を気にしたのはなぜですか?直接確率モデルではなく分類器を選択した理由は何ですか?
フランクハレル

回答:


18

両方の結果の標準偏差が同じ場合にのみ、素敵な対称ROCプロットが得られます。それらがかなり異なる場合は、説明したとおりの結果を得ることができます。

次のMathematicaコードはこれを示しています。ターゲットは応答空間で正規分布を生成し、ノイズも正規分布を生成しますが、変位したものと仮定します。ROCパラメーターは、判定基準の左右にあるガウス曲線の下の領域によって決定されます。この基準を変更すると、ROC曲線が記述されます。

Manipulate[
 ParametricPlot[{CDF[NormalDistribution[4, \[Sigma]], c], 
                 CDF[NormalDistribution[0, 3], c]
                }, {c, -10, 10}, 
                Frame -> True, 
                Axes -> None, PlotRange -> {{0, 1}, {0, 1}}, 
                Epilog -> Line[{{0, 0}, {1, 1}}]], 
 {{\[Sigma], 3}, 0.1, 10, Appearance -> "Labeled"}]

これは標準偏差が等しいものです: ここに画像の説明を入力してください

これはかなり明確なものです:

ここに画像の説明を入力してください

または、いくつかのパラメーターを使用して再生します。

Manipulate[
 ParametricPlot[{CDF[NormalDistribution[\[Mu]1, \[Sigma]1], c], 
   CDF[NormalDistribution[\[Mu]2, \[Sigma]2], c]}, {c, -100, 100}, 
  Frame -> True, Axes -> None, PlotRange -> {{0, 1}, {0, 1}}, 
  Epilog -> Line[{{0, 0}, {1, 1}}]], {{\[Mu]1, 0}, 0, 10, 
  Appearance -> "Labeled"},
 {{\[Sigma]1, 4}, 0.1, 20, Appearance -> "Labeled"},
 {{\[Mu]2, 5}, 0, 10, Appearance -> "Labeled"},
 {{\[Sigma]2, 4}, 0.1, 20, Appearance -> "Labeled"}]

ここに画像の説明を入力してください


1

FPRの高い曲線の部分に一連の負のインスタンスがあると、この種の曲線を作成できます。ROC曲線を生成するために適切なアルゴリズムを使用している限り、これは問題ありません。

半分が正で、半分が負である2mポイントのセットがある状態は、すべてモデルに対してまったく同じスコアを持っています。スコアに基づいてポイントを並べ替えるときに(ROCのプロットの標準手順)すべての負の例が最初に検出されると、ROC曲線がフラットのまま右に移動します。 :

フォーセット| ROC曲線のプロット


1

(@Sjoerd C. de Vriesと@Hrishekesh Ganuの答えは正しいです。それでもアイデアを別の方法で提示できると思いました。


モデルが誤って指定されている場合、そのようなROCを取得できます。以下の例(でコード化されているR)を考えてください。これは、ここでの私の答えです:箱ひげ図を使用して、値が異なる条件から来る可能性が高い点を見つける方法は?

## data
Cond.1 = c(2.9, 3.0, 3.1, 3.1, 3.1, 3.3, 3.3, 3.4, 3.4, 3.4, 3.5, 3.5, 3.6, 3.7, 3.7,
           3.8, 3.8, 3.8, 3.8, 3.9, 4.0, 4.0, 4.1, 4.1, 4.2, 4.4, 4.5, 4.5, 4.5, 4.6,
           4.6, 4.6, 4.7, 4.8, 4.9, 4.9, 5.5, 5.5, 5.7)
Cond.2 = c(2.3, 2.4, 2.6, 3.1, 3.7, 3.7, 3.8, 4.0, 4.2, 4.8, 4.9, 5.5, 5.5, 5.5, 5.7,
           5.8, 5.9, 5.9, 6.0, 6.0, 6.1, 6.1, 6.3, 6.5, 6.7, 6.8, 6.9, 7.1, 7.1, 7.1,
           7.2, 7.2, 7.4, 7.5, 7.6, 7.6, 10, 10.1, 12.5)
dat    = stack(list(cond1=Cond.1, cond2=Cond.2))
ord    = order(dat$values)
dat    = dat[ord,]  # now the data are sorted

## logistic regression models
lr.model1 = glm(ind~values,             dat, family="binomial")  # w/o a squared term
lr.model2 = glm(ind~values+I(values^2), dat, family="binomial")  # w/  a squared term
lr.preds1 = predict(lr.model1, data.frame(values=seq(2.3,12.5,by=.1)), type="response")
lr.preds2 = predict(lr.model2, data.frame(values=seq(2.3,12.5,by=.1)), type="response")

## here I plot the data & the 2 models
windows()
  with(dat, plot(values, ifelse(ind=="cond2",1,0), 
                 ylab="predicted probability of condition2"))
  lines(seq(2.3,12.5,by=.1), lr.preds1, lwd=2, col="red")
  lines(seq(2.3,12.5,by=.1), lr.preds2, lwd=2, col="blue")
  legend("bottomright", legend=c("model 1", "model 2"), lwd=2, col=c("red", "blue"))

ここに画像の説明を入力してください

赤いモデルにデータの構造が欠けていることは簡単にわかります。以下にプロットすると、ROC曲線がどのように見えるかがわかります。

library(ROCR)  # we'll use this package to make the ROC curve

## these are necessary to make the ROC curves
pred1 = with(dat, prediction(fitted(lr.model1), ind))
pred2 = with(dat, prediction(fitted(lr.model2), ind))
perf1 = performance(pred1, "tpr", "fpr")
perf2 = performance(pred2, "tpr", "fpr")

## here I plot the ROC curves
windows()
  plot(perf1, col="red",  lwd=2)
  plot(perf2, col="blue", lwd=2, add=T)
  abline(0,1, col="gray")
  legend("bottomright", legend=c("model 1", "model 2"), lwd=2, col=c("red", "blue"))

ここに画像の説明を入力してください

間違って指定された(赤)モデルの場合、偽陽性率が 80、偽陽性率は真陽性率よりも速く増加します。上記のモデルを見ると、そのポイントは、左下で赤と青の線が交差する場所であることがわかります。

弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.