Gestiona estimaciones e incertidumbre con un dotplot de intervalos

Visualize

Gestiona estimaciones e incertidumbre con un dotplot de intervalos

Creado: Última actualización: Tiempo de lectura: 1 min

En pruebas A/B o regresiones, mostrar intervalos de confianza junto al estimado puntual aumenta la credibilidad. El dotplot de intervalos es claro y compacto.

import numpy as np
import matplotlib.pyplot as plt

segments = ["Gratis", "Light", "Standard", "Premium"]
effect = np.array([0.12, 0.18, 0.27, 0.35])
low = effect - np.array([0.05, 0.06, 0.07, 0.08])
high = effect + np.array([0.05, 0.06, 0.07, 0.09])

fig, ax = plt.subplots(figsize=(6.4, 3.6))
ax.hlines(range(len(segments)), low, high, color="#94a3b8", linewidth=3)
ax.scatter(effect, range(len(segments)), color="#0ea5e9", s=90, zorder=3)

ax.axvline(0, color="#475569", linestyle="--", linewidth=1)
ax.set_yticks(range(len(segments)), labels=segments)
ax.set_xlabel("Mejora vs control")
ax.set_title("Efecto estimado con IC al 90%")
ax.set_xlim(-0.05, 0.45)
ax.grid(axis="x", alpha=0.2)

for idx, (eff, lo, hi) in enumerate(zip(effect, low, high)):
    ax.text(hi + 0.01, idx, f"{eff*100:.1f}% (+{(hi - eff)*100:.1f}/-{(eff - lo)*100:.1f})", va="center")

fig.tight_layout()

plt.show()

El dotplot de intervalos muestra la incertidumbre con claridad.

Consejos de lectura #

  • La longitud de la linea indica incertidumbre; lineas cortas significan estimaciones mas estables.
  • La linea en 0 ayuda a evaluar si el efecto cruza la neutralidad.
  • Cambia el tamano del punto para reflejar peso o tamaño muestral.