34 · Studiendesign zur Validierung klinischer KI-Systeme
silent_deployment_drift.png
Abbildung · Quellcode

Erzeugt von fig_silent_deployment_drift() in module/34-design-ki-studien/code/figures.py, Zeile 40–72.
Python
Python-Code: in eine Datei mit Endung
.py schreiben und mit dem ▶-Knopf in VS Code ausführen – oder Zeile für Zeile in die Python-Konsole. Setzt die in Modul 02 eingerichtete Umgebung voraus.def fig_silent_deployment_drift(drift: pd.DataFrame) -> None: fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(9.5, 4.6)) fig.subplots_adjust(top=0.78, bottom=0.3, wspace=0.32) ax1.plot(drift["month"], drift["auc"], "o-", color=PRIMARY, lw=2) ax1.set_ylim(0.5, 1.0) ax1.set_xlabel("Monat im Silent Deployment") ax1.set_ylabel("AUC") ax1.set_title("Diskriminierung (AUC)", loc="left") ax2.plot(drift["month"], drift["observed"], "o-", color=EVENT, lw=2, label="beobachtete Sterblichkeit") ax2.plot(drift["month"], drift["predicted"], "o-", color=PRIMARY, lw=2, label="mittleres vorhergesagtes Risiko") ax2.set_ylim(0, 0.4) ax2.set_xlabel("Monat im Silent Deployment") ax2.set_ylabel("Anteil") ax2.set_title("Kalibrierung im Mittel", loc="left") ax2.legend(loc="upper left", fontsize=8.6, frameon=False) last = drift.iloc[-1] ax2.annotate(f"O:E = {last['oe']:.2f}".replace(".", ","), (last["month"], last["observed"]), textcoords="offset points", xytext=(-62, 6), fontsize=9, color=EVENT) fig.suptitle("Dasselbe eingefrorene Modell, steigendes Grundrisiko:\n" "AUC bleibt gleich, die Risiken werden zunehmend unterschaetzt", fontsize=12.5, fontweight="bold", x=0.02, ha="left", y=0.98) slope0 = f"{drift['slope'].iloc[0]:.2f}".replace(".", ",") slope6 = f"{drift['slope'].iloc[-1]:.2f}".replace(".", ",") fig.text(0.02, 0.02, "Validierung an den zurueckgehaltenen Patient:innen. Simuliert: Log-Odds des Todes\n" "steigen jeden Monat um 0,15 bei gleichem Merkmalsprofil. Die Kalibrierungs-Steigung\n" f"bleibt nahe 1 ({slope0} -> {slope6}); nur das mittlere Niveau verschiebt sich.", fontsize=8.6, color="#6B7178") save(fig, ASSETS / "silent_deployment_drift.png")