def eval_F(list_data, worker, mu, C, W):
"""
F = log N(T, mu, C) + SUM q() log Ber(L_ij | T)
list_il can be from different datasets:
list_il = list: each elem is a list from a dataset
"""
res = scipy.stats.multivariate_normal.logpdf(W, mean = mu, cov = C, allow_singular = True)
for dt, data in enumerate(list_data):
# dataset dt: sen = W[2*dt], fpr = W[2*dt+1]
sen, fpr = W[2*dt], W[2*dt+1]
if worker in data.dic_wl:
for (item, label) in data.dic_wl[worker]:
# prob of being 1
qz = data.qz[item]
res += qz * np.log( Ber(S(sen), label) )
#res += qz * ( label*np.log(S(sen)) + (1-label)*np.log(S(sen)) )
res += (1-qz) * np.log( Ber(S(fpr), label) )
return res
评论列表
文章目录