16 · Diagnostische Genauigkeit und Schwellenwerte
diagnostik_schwellenwert.png
Abbildung · Quellcode

Erzeugt im Abschnitt „MODULE 16 · Diagnostic thresholds (Healthy vs. Diseased)" in data/figures.py, Zeile 674–711.
Dieses Skript läuft von oben nach unten. Der gemeinsame Vorspann — Bibliotheken, Kohorte laden, Plot-Stil — steht am Anfang der vollständigen Datei und gilt für alle Abbildungen darin.
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.# =========================================================================== # MODULE 16 · Diagnostic thresholds (Healthy vs. Diseased) # =========================================================================== print("[16] Diagnostik & Schwellenwert ...") x = np.linspace(0, 10, 300) healthy = stats.norm.pdf(x, 3.5, 1.0) diseased = stats.norm.pdf(x, 6.0, 1.2) fig, ax = plt.subplots(figsize=(8, 4.5)) ax.plot(x, healthy, color=PRIMARY, linewidth=2, label="Gesund (negativ)") ax.fill_between(x, healthy, alpha=0.10, color=PRIMARY) ax.plot(x, diseased, color=EVENT, linewidth=2, label="Krank (positiv)") ax.fill_between(x, diseased, alpha=0.10, color=EVENT) # Cut-off at 4.8 cutoff = 4.8 ax.axvline(cutoff, color="#16181C", linestyle="-", linewidth=1.5) ax.text(cutoff + 0.1, 0.35, "Schwellenwert\n(Cut-off)", color="#16181C", fontsize=10, fontweight="semibold") # Fill errors: False Positives (Healthy above cutoff) fp_x = x[x >= cutoff] ax.fill_between(fp_x, stats.norm.pdf(fp_x, 3.5, 1.0), color=PRIMARY, alpha=0.4, label="Falsch-Positiv (FP)") # Fill errors: False Negatives (Diseased below cutoff) fn_x = x[x < cutoff] ax.fill_between(fn_x, stats.norm.pdf(fn_x, 6.0, 1.2), color=EVENT, alpha=0.4, label="Falsch-Negativ (FN)") ax.set_xlabel("Biomarker-Konzentration (z.B. Laktat, CRP)") ax.set_ylabel("Wahrscheinlichkeitsdichte") ax.set_title("Diagnostischer Schwellenwert & Klassifikationsfehler") ax.legend(loc="upper right") ax.grid(True, linestyle=":", alpha=0.6) (ASSETS / "16-diagnostik-schwellen" / "assets").mkdir(parents=True, exist_ok=True) save(fig, ASSETS / "16-diagnostik-schwellen" / "assets" / "diagnostik_schwellenwert.png")