14 · Fehlende Werte und Imputation
mice_konvergenz.png
Abbildung · Quellcode

Erzeugt von _figure_convergence() in module/14-fehlende-werte/code/mice_praxis.py, Zeile 410–427.
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 _figure_convergence(chain_means: np.ndarray, chain_sds: np.ndarray) -> None: apply_style() n_iter, n_chains = chain_means.shape it = np.arange(1, n_iter + 1) fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(8.5, 7.5), sharex=True) for c in range(n_chains): color = PALETTE[c % len(PALETTE)] ax1.plot(it, chain_means[:, c], color=color, marker="o", markersize=3, label=f"Kette {c + 1}") ax2.plot(it, chain_sds[:, c], color=color, marker="o", markersize=3, label=f"Kette {c + 1}") ax1.set_ylabel("Mittelwert (imputiert)") ax1.set_title("Konvergenz der MICE-Ketten für bga_ph", fontsize=13.5) ax2.set_ylabel("Standardabweichung (imputiert)") ax2.set_xlabel("Iteration") ax1.legend(ncol=n_chains, fontsize=8.5, loc="upper right") fig.tight_layout() save(fig, ASSETS / "mice_konvergenz.png")