[英]Python plot multiple z-test result with confidence interval (visualize A/B test results)
Hi, I want to visualize results for one A/B test.嗨,我想可视化一项 A/B 测试的结果。 The experiment tracks 4 metrics, and I want to show them in one plot altogether.
该实验跟踪 4 个指标,我想将它们全部显示在一个 plot 中。 The schema of my dataframe is:
我的 dataframe 的架构是:
test_control |测试控制 | metric1 |
公制1 | metric2 |
公制2 | metric3 |
公制3 | metric4
公制4
Does anyone know how to plot, by matplotlib, pandas or seaborn?有谁知道如何 plot,通过 matplotlib,pandas 或 ZD50F42A37901F21D0A36ZDF3E?
Thanks in advance!提前致谢!
I found it's probably easier to be done in R.我发现在 R 中可能更容易完成。 In python, I calculated the error bar and then used matplotlib.pyplot.errorbar to plot:
在 python 中,我计算了误差条,然后将 matplotlib.pyplot.errorbar 用于 plot:
kpi_map = {'kpi':[], 'mean_diff':[], 'err':[], 'pval':[]}
for col in metrics:
sp1 = df.loc[df['test_control']=='test'][col]
sp2 = df.loc[df['test_control']=='control'][col]
std1 = np.std(sp1, ddof=1)
std2 = np.std(sp2, ddof=1)
mean_diff_std = (std1**2/len(sp1) + std2**2/len(sp2)) **0.5
mean_diff = sp1.mean() - sp2.mean()
kpi_map['kpi'].append(col)
kpi_map['mean_diff'].append(mean_diff)
kpi_map['err'].append(1.96*mean_diff_std)
df_kpi = pd.DataFrame(data = kpi_map)
plt.errorbar(y=df_kpi['kpi'], x=df_kpi['mean_diff'], xerr=df_kpi['err'], fmt='o', elinewidth=2, capsize=4, capthick=2)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.