def train_pumil_clf(bags, pidx, uidx, w, NL, learning_phase = False):
# top-{NL} reliable negative bags
relnidx = reliable_negative_bag_idx(bags, uidx, w, NL)
Bn = [bags[j] for j in relnidx]
# estimated p(X|Y=-1) via WKDE
Dn = weighted_kde(Bn, w[relnidx])
# form Positive Margin Pool (PMP)
pmp_x, pmp_y, pmp_conf = form_pmp(bags, w, pidx, relnidx, Dn)
# train SVM by using PMP instances
pmp_weighted_x = np.multiply(pmp_x.T, pmp_conf).T
clf = svm.LinearSVC(loss = 'hinge')
clf.fit(pmp_weighted_x, pmp_y)
clf_ = pumil_clf_wrapper(lambda x: float(clf.decision_function(x)), Dn, learning_phase)
if learning_phase:
return clf_, relnidx
else:
return clf_
评论列表
文章目录