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

31 · Verarbeitung klinischer Freitexte mit LLMs

text_roc.png

Abbildung · Quellcode

text_roc

Erzeugt von fig_text_roc() in module/31-klinische-texte-llm/code/figures.py, Zeile 80–93.

Python
def fig_text_roc(pipe: Pipeline, X_test, y_test) -> None:
    """ROC curve for the text classifier on the held-out test set."""
    proba = pipe.predict_proba(X_test)[:, 1]
    fpr, tpr, _ = roc_curve(y_test, proba)
    auc = roc_auc_score(y_test, proba)

    fig, ax = plt.subplots(figsize=(5.5, 5))
    ax.plot(fpr, tpr, color=PRIMARY, lw=2, label=f"TF-IDF + LogReg (AUC = {auc:.2f})")
    ax.plot([0, 1], [0, 1], color=SECONDARY, lw=0.9, ls="--", label="Zufallsklassifikator")
    ax.set_xlabel("Falsch-Positiv-Rate (1 – Spezifität)")
    ax.set_ylabel("Richtig-Positiv-Rate (Sensitivität)")
    ax.set_title("ROC-Kurve: Textklassifikator für Verschlechterung")
    ax.legend(loc="lower right")
    save(fig, ASSETS / "text_roc.png")

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