我有一个人类预报员中的概率预测列表和一个匹配的真相列表。
sklearn.calibration.calibration_curve使创建校准曲线非常容易,但是我不确定如何计算出图中每个点的95%CI。
我尝试使用binom_test为每个点手动计算该值
import statsmodels.api as sm
from sklearn.calibration import calibration_curve
calib_y, calib_x = calibration_curve(truth, my_forecast, n_bins=20)
levels=list(set(my_forecast))
levels.sort()
ci=[]
i=0
for my_prob in levels:
forecast_index=sum(np.where(my_forecast==my_prob))
n=len(forecast_index)
p=calib_y[i]
AA=sm.stats.proportion_confint(count=n*p, nobs=n, alpha=0.05, method='binom_test')
ci.append(AA)
i=i+1
# Transpose ci so it'll work with pyplot.errorbar
ci=np.transpose(ci)
我正在获取一个输出矩阵,但是不能100%地确定这是否是正确的方法。