Gerencie estimativas e incerteza com um interval dotplot

Visualize

Gerencie estimativas e incerteza com um interval dotplot

Created: Last updated: Read time: 1 min

Em testes A/B ou regressao, mostrar o intervalo de confianca junto da estimativa pontual aumenta a credibilidade. O interval dotplot e simples e facil de ler.

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("Lift vs controle")
ax.set_title("Estimativas com IC de 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()

O interval dotplot deixa a incerteza visivel.

Dicas de leitura #

  • O comprimento da linha mostra a incerteza; linhas menores indicam estimativas mais estaveis.
  • A linha em 0 ajuda a ver se o efeito cruza a neutralidade.
  • Ajuste o tamanho do ponto para representar peso ou tamanho de amostra.