Exemple #1
0
    def test_random(self):
        """
        Test random sampling of mixture node
        """

        o = 1e-20
        X = Mixture([1, 0, 2], Categorical,
                    [[o, o, o, 1], [o, o, 1, o], [1, o, o, o]])
        x = X.random()
        self.assertAllClose(x, [2, 3, 0])

        pass
Exemple #2
0
    def test_random(self):
        """
        Test random sampling of mixture node
        """

        o = 1e-20
        X = Mixture([1, 0, 2], Categorical, [ [o, o, o, 1],
                                              [o, o, 1, o],
                                              [1, o, o, o] ])
        x = X.random()
        self.assertAllClose(x, [2, 3, 0])

        pass
Exemple #3
0
Lambda = Wishart(D, 1e-5 * np.identity(D), plates=(K, ), name='Lambda')

Y = Mixture(Z, Gaussian, mu, Lambda, name='Y')

Z.initialize_from_random()

Q = VB(Y, mu, Lambda, Z, alpha)

Y.observe(y)

Q.update(repeat=1000)

bpplt.gaussian_mixture_2d(Y, alpha=alpha, scale=2)

Q.compute_lowerbound()
Y.random()

from sklearn.mixture import BayesianGaussianMixture

# DD
fin_gmm = BayesianGaussianMixture(
    weight_concentration_prior_type="dirichlet_distribution",
    covariance_type='full',
    weight_concentration_prior=1.2,
    n_components=10,
    reg_covar=0,
    init_params='random',
    max_iter=1500,
    mean_precision_prior=.8)

fitted = fin_gmm.fit(X)