def makeModel(Data, lam0=0.1, lam1=0.1, **kwargs): PriorArgs = dict(lam1=lam1, lam0=lam0) PriorArgs.update(kwargs) allocModel = bnpy.allocmodel.DPMixtureModel('VB', gamma0=1.0) obsModel = bnpy.obsmodel.BernObsModel('VB', Data=Data, **PriorArgs) model = bnpy.HModel(allocModel, obsModel) return model
def makeModel(Data, ECovMat='diagcovdata', sF=1.0, **kwargs): PriorArgs = dict(sF=sF, ECovMat=ECovMat) PriorArgs.update(kwargs) allocModel = bnpy.allocmodel.DPMixtureModel('VB', gamma0=1.0) obsModel = bnpy.obsmodel.GaussObsModel('VB', Data=Data, **PriorArgs) model = bnpy.HModel(allocModel, obsModel) return model
def setUp(self, N=100, Data=None, likelihood='Gauss', **kwargs): GaussSpec.update(kwargs) DPSpec.update(kwargs) if Data is None: Data = makeGaussianDataWithTwoComps(N=N) self.Data = Data self.oneresp = 1e-50 * np.ones((2 * N, 2)) self.oneresp[:, 0] = 1.0 self.trueresp = 1e-50 * np.ones((2 * N, 2)) self.trueresp[:N, 0] = 1.0 self.trueresp[N:, 1] = 1.0 amodel = bnpy.allocmodel.DPMixtureModel('VB', DPSpec) if likelihood.count('ZeroMean'): omodel = bnpy.obsmodel.ZeroMeanGaussObsModel('VB', Data=self.Data, **GaussSpec) else: omodel = bnpy.obsmodel.GaussObsModel('VB', Data=self.Data, **GaussSpec) self.hmodel = bnpy.HModel(amodel, omodel)