感度・特異度・ROC曲線

2×2表、閾値、ROC曲線、AUCを通じて診断検査の性能評価をわかりやすく解説します。

Medical StatisticsSensitivitySpecificityROC

はじめに

診断検査の性能を評価するとき、中心となるのが

  • 感度(Sensitivity)
  • 特異度(Specificity)
  • ROC曲線
  • AUC

です。この記事では、2×2表からROC/AUCまでを一つの流れで整理します。

1. 2×2分割表

実際の状態(疾患あり/なし)と検査結果(陽性/陰性)を組み合わせると、

  • TP(真陽性)
  • FP(偽陽性)
  • FN(偽陰性)
  • TN(真陰性)

の4つに分かれます。

ここから

Sensitivity=TPTP+FN,Specificity=TNTN+FP\text{Sensitivity}=\frac{TP}{TP+FN},\qquad \text{Specificity}=\frac{TN}{TN+FP}

を計算します。

2. 閾値によるトレードオフ

検査値の閾値を下げると陽性判定が増え、

  • 感度は上がりやすい
  • 特異度は下がりやすい

というトレードオフが生じます。

3. ROC曲線

ROC曲線は、閾値を動かしたときの

  • 横軸:偽陽性率 FPR=1Specificity\text{FPR}=1-\text{Specificity}
  • 縦軸:真陽性率 TPR=Sensitivity\text{TPR}=\text{Sensitivity}

を結んだ曲線です。

左上に近いほど性能が高く、対角線はランダム分類を表します。

Interactive Threshold Slider with 2×2 Table

0.00 (More Sensitive)1.00 (More Specific)

2×2 Confusion Matrix

Disease Present
Disease Absent
Test Positive
31
True Positive
10
False Positive
Test Negative
9
False Negative
50
True Negative

Calculated Metrics

Sensitivity (True Positive Rate)
77.5%
TP / (TP + FN) = 31 / (31 + 9)
Specificity (True Negative Rate)
83.3%
TN / (TN + FP) = 50 / (50 + 10)
Positive Predictive Value
75.6%
TP / (TP + FP) = 31 / (31 + 10)
Negative Predictive Value
84.7%
TN / (TN + FN) = 50 / (50 + 9)

Test Score Distribution

🔴 Disease Present🔵 Disease Absent📏 Yellow border = Test Positive

Instructions: Move the threshold slider to see how changing the cutoff value affects the 2×2 table and calculated metrics. Lower thresholds increase sensitivity but decrease specificity, and vice versa. This demonstrates the fundamental tradeoff in diagnostic testing.

4. AUC(曲線下面積)

AUCはROC曲線を1つの数値で要約した指標です。

  • 1に近いほど優秀
  • 0.5付近ならランダム並み

実務では台形公式で近似することが多く、

AUCtrap=i=1n1(FPRi+1FPRi)TPRi+1+TPRi2\text{AUC}_{\text{trap}} = \sum_{i=1}^{n-1} (FPR_{i+1}-FPR_i)\frac{TPR_{i+1}+TPR_i}{2}

で計算できます。

ROC生成のシミュレーション

次のデモで、しきい値を変えたときにROC曲線がどう作られるかを確認できます。

Live ROC Curve Builder

Current Point Metrics

80.0%
Sensitivity (TPR)
15.0%
False Positive Rate
True Positives: 64
False Positives: 18
True Negatives: 102
False Negatives: 16

Area Under Curve (AUC)

0.950
Perfect test: 1.000
Random test: 0.500
Current test: Excellent

About AUC

The AUC represents the probability that the test will correctly rank a randomly chosen positive case higher than a randomly chosen negative case.

Calculated using the trapezoidal rule for numerical integration.

ROC Curve

False Positive Rate (1 - Specificity)Sensitivity (True Positive Rate)0.00.00.20.20.40.40.60.60.80.81.01.0

🔴 Red dot: Current threshold point
🔵 Blue line: Complete ROC curve
Gray dashed: Random classifier (AUC = 0.5)

Instructions: Adjust the threshold slider to see how each point on the ROC curve is generated. Click "Animate ROC Building" to watch the curve being constructed point by point. The AUC represents the overall discriminative ability of the test - a perfect test would hug the top-left corner (AUC = 1.0), while a random test follows the diagonal (AUC = 0.5).

まとめ

  • 2×2表から感度・特異度を定義できる。
  • 閾値調整により両者はトレードオフ関係になる。
  • ROC曲線はその関係を可視化し、AUCは全体性能を1つの数値で示す。
← 図鑑に戻る