def subsample(self, fcs, *args, **kwargs): x = fcs[:] neg_py = mixnormpdf(x, self.neg.pis, self.neg.mus, self.neg.sigmas, logged=True, *args, **kwargs) pos_py = mixnormpdf(x, self.pos.pis, self.pos.mus, self.pos.sigmas, logged=True, *args, **kwargs) diff = pos_py - neg_py probs = np.exp(diff) probs = probs / np.sum(probs) samp = npr.choice(np.arange(x.shape[0]), size=self.n, replace=False, p=probs) if isinstance(fcs, fcm.FCMdata): node = SubsampleNode("", fcs.get_cur_node(), samp) fcs.add_view(node) return fcs else: return x[samp]
def subsample(self, fcs): x = fcs[:] samp = npr.choice(np.arange(x.shape[0]), self.n) if isinstance(fcs, fcm.FCMdata): node = SubsampleNode("", fcs.get_cur_node(), samp) fcs.add_view(node) return fcs else: return x[samp]
def subsample(self, fcs, *args, **kwargs): x = fcs[:] p = mixnormpdf(x, self.neg.pis, self.neg.mus, self.neg.sigmas) p = 1 / p p = p / np.sum(p) samp = npr.choice(np.arange(x.shape[0]), size=self.n, replace=False, p=p) if isinstance(fcs, fcm.FCMdata): node = SubsampleNode("", fcs.get_cur_node(), samp) fcs.add_view(node) return fcs else: return x[samp]
def subsample(self, fcs): """D(<fcmdata>) -> leads to a new fcm view of subsampled data""" node = SubsampleNode("", fcs.get_cur_node(), self.samp) fcs.add_view(node) return fcs