def mfm(sampler=hybrid, offset=0, gamma=1): return { "sampler": sampler, "mixture": lambda nc: bmcc.MFM(gamma=gamma, prior=lambda k: poisson.logpmf(k, nc + offset)) }
d=3, r=0.7, alpha=40, df=3, symmetric=False, shuffle=False) def hybrid(*args, **kwargs): for _ in range(5): bmcc.gibbs(*args, **kwargs) bmcc.split_merge(*args, **kwargs) mm = bmcc.MFM(gamma=1, prior=lambda k: poisson.logpmf(k, 3)) # mm = bmcc.DPM(alpha=1, use_eb=False) cm = bmcc.NormalWishart(df=3) # Create mixture model model = bmcc.BayesianMixture(data=dataset.data, sampler=hybrid, component_model=cm, mixture_model=mm, assignments=np.zeros(POINTS).astype(np.uint16), thinning=THINNING) # Run Iterations start = time.time() for i in tqdm(range(ITERATIONS)): model.iter()
# Create dataset dataset = bmcc.GaussianMixture(n=1000, k=4, d=3, r=0.7, alpha=40, df=3, symmetric=False, shuffle=False) # Create mixture models model_mfm = bmcc.GibbsMixtureModel( data=dataset.data, component_model=bmcc.NormalWishart(df=3), mixture_model=bmcc.MFM(gamma=1, prior=lambda k: poisson.logpmf(k, 4)), assignments=np.zeros(1000).astype(np.uint16), thinning=5) model_dpm = bmcc.GibbsMixtureModel( data=dataset.data, component_model=bmcc.NormalWishart(df=3), mixture_model=bmcc.DPM(alpha=1, use_eb=True), assignments=np.zeros(1000).astype(np.uint16), thinning=5) # Run Iterations print("MFM:") for i in tqdm(range(5000)): model_mfm.iter() print("DPM:") for i in tqdm(range(5000)):