Bases: object
Internal class used for accumulation for GMM training - you shouldn’t be making these yourself.
>>> g0 = GmmAccumSet(10, 33, gaussian.GaussianModelBase.DIAGONAL_COVARIANCE)
Compute weights, means, and vars from accum set.
Merge another accum set into this one
Bases: onyx.am.gmm_trainer.Trainer
>>> m0 = gaussian.GaussianMixtureModel(3, gaussian.GaussianModelBase.DIAGONAL_COVARIANCE, 2)
>>> m0.set_weights(np.array((0.75, 0.25)))
>>> mu = np.array(((1, 1, 1), (3, 3, 3)))
>>> m0.set_means(mu)
>>> v = np.array(((1, 1, 1), (1, 1, 1)))
>>> m0.set_vars(v)
>>> m0.seed(0)
>>> data0 = np.array([m0.sample() for _ in xrange(200)], dtype=float).transpose()
>>> m1 = gaussian.GaussianMixtureModel(3, gaussian.GaussianModelBase.DIAGONAL_COVARIANCE, 2)
>>> m1.init_models()
>>> print m1
Gmm: (Type = diagonal, Dim = 3, NumComps = 2)
Weights Models
0.5000 Means: -0.3997 0.1183 0.9441 Vars: 0.7000 0.7000 0.7000
0.5000 Means: -1.0006 1.5618 -0.7573 Vars: 0.7000 0.7000 0.7000
>>> gmm_tr1 = GmmTrainer(m1)
>>> gmm_tr1.train(data0)
>>> print m1
Gmm: (Type = diagonal, Dim = 3, NumComps = 2)
Weights Models
0.4641 Means: 1.9168 2.2232 2.2034 Vars: 2.0687 1.7396 1.1752
0.5359 Means: 0.7015 0.8667 0.8024 Vars: 0.8496 0.7484 0.7699
>>> m2 = gaussian.GaussianMixtureModel(3, gaussian.GaussianModelBase.FULL_COVARIANCE, 2)
>>> m2.init_models()
>>> print m2
Gmm: (Type = full, Dim = 3, NumComps = 2)
Weights Models
0.5000 Means: 1.4930 0.0120 0.1124 Vars:
0.7000 0.0000 0.0000
0.0000 0.7000 0.0000
0.0000 0.0000 0.7000
0.5000 Means: -0.1175 -0.2294 -0.6498 Vars:
0.7000 0.0000 0.0000
0.0000 0.7000 0.0000
0.0000 0.0000 0.7000
>>> data1 = np.array([m0.sample() for _ in xrange(800)], dtype=float).transpose()
>>> gmm_tr2 = GmmTrainer(m2)
>>> gmm_tr2.train(data1)
>>> print m2
Gmm: (Type = full, Dim = 3, NumComps = 2)
Weights Models
0.6864 Means: 1.8985 1.7657 1.8274 Vars:
1.8164 0.9724 0.8152
0.9724 2.0158 0.9202
0.8152 0.9202 1.7895
0.3136 Means: 0.5914 1.0580 0.8863 Vars:
0.5956 -0.2138 -0.0857
-0.2138 0.7284 -0.1301
-0.0857 -0.1301 0.7710
Bases: object