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

23 · Einführung in das maschinelle Lernen

roc_kurve.png

Abbildung · Quellcode

roc_kurve

Erzeugt von fig_roc() in module/23-machine-learning/code/figures.py, Zeile 39–55.

Python
def fig_roc(y_test, proba) -> None:
    fpr, tpr, _ = roc_curve(y_test, proba)
    auc_val = roc_auc_score(y_test, proba)

    fig, ax = plt.subplots(figsize=(6, 6))
    ax.plot(fpr, tpr, color=PRIMARY, linewidth=2.2,
            label=f"Logistische Regression (AUC = {auc_val:.3f})")
    ax.plot([0, 1], [0, 1], color=SECONDARY, linestyle="--", linewidth=1.0,
            label="Zufallsklassifikator (AUC = 0.500)")
    ax.fill_between(fpr, tpr, alpha=0.10, color=PRIMARY)
    ax.set_xlabel("Falsch-Positiv-Rate (1 − Spezifität)")
    ax.set_ylabel("Richtig-Positiv-Rate (Sensitivität)")
    ax.set_title(f"ROC-Kurve: 30-Tage-Mortalität\n(Testdaten, N = {len(y_test)})")
    ax.legend(loc="lower right")
    ax.set_xlim(0, 1)
    ax.set_ylim(0, 1.02)
    save(fig, ASSETS / "roc_kurve.png")

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