感度・特異度・ROC曲線
2×2表、閾値、ROC曲線、AUCを通じて診断検査の性能評価をわかりやすく解説します。
はじめに
診断検査の性能を評価するとき、中心となるのが
- 感度(Sensitivity)
- 特異度(Specificity)
- ROC曲線
- AUC
です。この記事では、2×2表からROC/AUCまでを一つの流れで整理します。
1. 2×2分割表
実際の状態(疾患あり/なし)と検査結果(陽性/陰性)を組み合わせると、
- TP(真陽性)
- FP(偽陽性)
- FN(偽陰性)
- TN(真陰性)
の4つに分かれます。
ここから
を計算します。
2. 閾値によるトレードオフ
検査値の閾値を下げると陽性判定が増え、
- 感度は上がりやすい
- 特異度は下がりやすい
というトレードオフが生じます。
3. ROC曲線
ROC曲線は、閾値を動かしたときの
- 横軸:偽陽性率
- 縦軸:真陽性率
を結んだ曲線です。
左上に近いほど性能が高く、対角線はランダム分類を表します。
Interactive Threshold Slider with 2×2 Table
2×2 Confusion Matrix
Calculated Metrics
Test Score Distribution
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付近ならランダム並み
実務では台形公式で近似することが多く、
で計算できます。
ROC生成のシミュレーション
次のデモで、しきい値を変えたときにROC曲線がどう作られるかを確認できます。
Live ROC Curve Builder
Current Point Metrics
Area Under Curve (AUC)
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
🔴 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つの数値で示す。