Data Science · Klinik Klinische Datenanalyse & Machine Learning
Ansicht
Lerntiefe
Codeansicht
Farbschema

25 · Bewertung der Modellgüte und klinische Validierung

decision_curve.png

Abbildung · Quellcode

decision_curve

Erzeugt von fig_decision_curve() in module/25-modellguete-validierung/code/figures.py, Zeile 80–99.

Python
def fig_decision_curve(y_test, proba) -> None:
    thresholds = np.linspace(0.01, 0.50, 200)
    base_rate = float(np.mean(y_test))

    nb_model = [net_benefit(y_test, proba, t) for t in thresholds]
    nb_all   = [base_rate - (t / (1 - t)) * (1 - base_rate) for t in thresholds]
    nb_none  = [0.0] * len(thresholds)

    fig, ax = plt.subplots(figsize=(7, 4.5))
    ax.plot(thresholds, nb_model, color=PRIMARY,    lw=2,   label="Logistisches Modell")
    ax.plot(thresholds, nb_all,   color=EVENT,      lw=1.5, ls="-.", label="Alle behandeln")
    ax.plot(thresholds, nb_none,  color=SECONDARY,  lw=1.2, ls="--",  label="Niemanden behandeln")
    ax.axhline(0, color="#CCCCCC", lw=0.8)
    ax.set_xlim(0.01, 0.50)
    ax.set_ylim(-0.05, None)
    ax.set_xlabel("Entscheidungsschwelle")
    ax.set_ylabel("Nettovorteil (Net Benefit)")
    ax.set_title("Decision-Curve-Analyse: Klinischer Nutzen des Modells (rekalibriert)")
    ax.legend(loc="upper right")
    save(fig, ASSETS / "decision_curve.png")

← zurück zu Modul 25 · vollständige Datei ansehen