キャリブレーションプロット
十分位ごとの予測リスク対観測リスクを、ウィルソン信頼区間、予測値のヒストグラム、ブライアスコアとともに示します。

モデルは事例をうまく順位付けできても(AUC が高くても)、誤った確率を出すことがあります。信頼性ダイアグラムはこれを確認するためのものです。テスト事例を予測リスクの十分位でグループ分けし、各ビンの平均予測値を観測されたイベント発生率に対して 95% ウィルソン区間とともにプロットします。較正の取れたモデルは対角線上に並び、高リスク側で対角線より下(低リスク側で上)にある点はモデルが過信していることを意味します。下のヒストグラムは、予測値が実際にどこに分布しているかを示しています。
設定は Zarea et al. (2026, Journal of Information Technology Management) による、リスク主導の能力開発とサプライチェーンのレジリエンスの研究です。データは説明のために シミュレーション したもので、論文のデータや結果ではありません。n = 3,000 社で、アウトカムは企業が大規模なサプライチェーンの途絶を経験したかどうか、説明変数はサプライヤーの集中度、地理的リスクへのエクスポージャー、リードタイムのばらつき(同じエクスポージャーを測る相関した3つの指標)とデジタル化指数です。データは 70/30 に分割しています。scikit-learn のロジスティック回帰とガウス型ナイーブベイズを比較しており、ナイーブベイズは相関した3つのシグナルを独立した証拠として数えてしまいます。ブライアスコア(brier_score_loss、低いほど良い)は確率の正確さを要約し、区間は proportion_confint(method="wilson") から求めています。
コードおよび図中のテキストは英語です。
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import brier_score_loss
from sklearn.model_selection import train_test_split
from sklearn.naive_bayes import GaussianNB
from statsmodels.stats.proportion import proportion_confint
# Simulated data, set in the context of Zarea et al. (2026) [zarea2026]
# Data: 3,000 firms; three noisy measures of one latent exposure + digitalisation
rng = np.random.default_rng(2026)
n = 3000
exposure = rng.normal(size=n)
X = np.column_stack([exposure + rng.normal(0, 0.6, n), # supplier concentration
exposure + rng.normal(0, 0.6, n), # geographic risk exposure
exposure + rng.normal(0, 0.6, n), # lead-time variability
rng.normal(size=n)]) # digitalisation index
eta = -1.4 + 0.3 * X[:, :3].sum(axis=1) - 0.5 * X[:, 3]
y = rng.binomial(1, 1 / (1 + np.exp(-eta))) # 1 = major disruption
X_tr, X_te, y_tr, y_te = train_test_split(X, y, test_size=0.3, stratify=y, random_state=1)
models = {"Logistic regression": (LogisticRegression(max_iter=1000), "#007AFF", "o"),
"Naive Bayes": (GaussianNB(), "#FF9500", "s")}
fig, (ax, axh) = plt.subplots(2, 1, figsize=(7, 7.4), sharex=True,
gridspec_kw=dict(height_ratios=[4, 1.1], hspace=0.05))
ax.plot([0, 1], [0, 1], color="#AEAEB2", lw=1, ls="--", label="Perfect calibration")
bins = np.linspace(0, 1, 41)
for name, (clf, c, mk) in models.items():
p = clf.fit(X_tr, y_tr).predict_proba(X_te)[:, 1]
# Group predictions into deciles of predicted risk
tab = (pd.DataFrame({"p": p, "y": y_te})
.assign(bin=lambda d: pd.qcut(d.p, 10, labels=False, duplicates="drop"))
.groupby("bin").agg(pred=("p", "mean"), obs=("y", "mean"), k=("y", "sum"), n=("y", "size")))
lo, hi = proportion_confint(tab.k, tab.n, method="wilson")
ax.errorbar(tab.pred, tab.obs, yerr=[tab.obs - lo, hi - tab.obs], fmt=mk + "-", color=c,
ms=7, mec="white", mew=1.2, lw=1.6, capsize=0, elinewidth=1.4,
label=f"{name} · Brier = {brier_score_loss(y_te, p):.3f}")
axh.hist(p, bins=bins, color=c, alpha=0.15, lw=0)
axh.hist(p, bins=bins, color=c, histtype="step", lw=1.4)
ax.set_xlim(0, 1); ax.set_ylim(0, 1); ax.set_aspect("auto")
ax.grid(axis="x")
ax.set_ylabel("Observed share of firms with a disruption")
ax.legend(loc="upper left", alignment="left", title="Deciles of predicted risk, 95% Wilson CI")
axh.set_xlabel("Predicted probability of a supply-chain disruption")
axh.set_ylabel("Count", fontsize=10)
axh.grid(axis="x")
ax.set_title("Naive Bayes is over-confident; logistic regression is well calibrated", pad=26)
ax.text(0, 1.02, f"Test set n = {len(y_te):,} firms (simulated) · base rate = {y_te.mean():.0%} · "
f"Brier of the base-rate guess = {y_te.mean() * (1 - y_te.mean()):.3f}",
transform=ax.transAxes, fontsize=9.5, color="#6E6E73")
plt.show()
図にはオプションの PyStatlas スタイル を使用しています。同じ見た目にするには plt.style.use("pystatlas.mplstyle") を追加してください。
データの出典
- Simulated data. Simulated data with a fixed random seed, created for this example.
No real respondents, documents or measurements: the numbers only illustrate how the chart and its statistics work. - Zarea et al. (2026), supply-chain resilience and digitalisation. Zarea, H., Moghaddamzadeh, H., Moradi, M., Hassani, A., Warin, T., & Stojkov, A. (2026). Risk-driven capability development in global supply chain resilience: Implications for digitalization. Journal of Information Technology Management, 82–107. https://jitm.ut.ac.ir/article_108005.html
The example is set in the context of this paper; unless its description says otherwise, the numbers are simulated and are not the paper's data or results.
これらの例は統計手法を説明するためのものです。項目に別の記載がない限り数値はシミュレーションであり、図のタイトルはこのシミュレーションデータで図が示す内容を述べたものです。引用した論文の知見でも、実質的な問いに対する著者の立場でもありません。結果、背景、データについては、ここに挙げた論文を参照してください。
引用方法
PyStatlas は Thierry Warin が作成・運営しています。研究や業務に役立った場合は、ぜひ引用してください。
Warin, T. (2026). Calibration plot. In PyStatlas: A Python Gallery of Statistical Graphics for the Social Sciences (Version 1.1.0) [Computer software]. https://warin.ca/pystatlas/model-diagnostics/calibration-plot/
@misc{warin2026statlas,
author = {Warin, Thierry},
title = {PyStatlas: A Python Gallery of Statistical Graphics for the Social Sciences},
year = {2026},
version = {1.1.0},
howpublished = {\url{https://warin.ca/pystatlas/}},
note = {Source code: https://github.com/warint/pystatlas}
}