pumil.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:pumil 作者: levelfour 项目源码 文件源码
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_
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号