Gaussian Mixture Model and Audio analysis

62 views
Skip to first unread message

jamieol...@gmail.com

unread,
Jan 27, 2014, 12:16:43 PM1/27/14
to accor...@googlegroups.com
Hi there,

I am trying to make an GMM of Audio data. Therefore, I do an Mel Frequency Cepstral Coefficient analysis for each sample and store the data in an array:

double[][] data;

Then I do initialize the gmm with KMeans.
When I try to make the gmm I get an NonPositiveDefiniteMatrixException at the compute call.


double[] weights = { 1, 3, 5, 4, 3, 5, 10, 17, 12, 6, 3, 1, 0 };

int numberClusters = 11;
KMeans kmeans = new KMeans(numberClusters);

kmeans.Compute(melFrequencies, 0.0001);
GaussianMixtureModel gmm = new GaussianMixtureModel(numberClusters);

if (kmeans != null) gmm.Initialize(kmeans);

gmm.Compute(melFrequencies, new GaussianMixtureModelOptions()
{
//Weights = weights
});

int[] classifications = gmm.Gaussians.Nearest(melFrequencies);


Please, help me I really don't know how to get this running.

Thanks & Best regards,
James

César

unread,
Jan 29, 2014, 4:58:33 AM1/29/14
to accor...@googlegroups.com
Hi James,

One way to avoid the non-positive problem would be to set the Robust property to true in the NormalOptions of the GaussianMixtureModelOptions object. For example, perhaps the following would make it work:

            double[] weights =  {   1, 3, 5, 4, 3, 5, 10, 17, 12, 6, 3, 1, 0 };



           
int numberClusters = 11;
           
KMeans kmeans = new KMeans(numberClusters);
           
            kmeans
.Compute(melFrequencies, 0.0001);
           
GaussianMixtureModel gmm = new GaussianMixtureModel(numberClusters);

           
if (kmeans != null) gmm.Initialize(kmeans);
           
            gmm
.Compute(melFrequencies, new GaussianMixtureModelOptions()
           
{
                 
//Weights = weights

                 
NormalOptions = new NormalOptions()
                 {
                     
Robust = true;

                 
}
           
});

           
int[] classifications = gmm.Gaussians.Nearest(melFrequencies);


Hope it helps!

Cesar

jamieol...@gmail.com

unread,
Feb 3, 2014, 8:35:18 PM2/3/14
to accor...@googlegroups.com
Hi,

thanks that solved the problem with getting the gmm run.

One thing I wonder still wonder:
The calculated classifactions have all the same integer as a result.
I guess I still do something wrong...

Thanks, James

César

unread,
Feb 4, 2014, 4:11:05 AM2/4/14
to accor...@googlegroups.com
This might happen when there are too many samples to be clustered. One possible way to overcome this problem would be to set the Logarithm property to true in the GaussianMixtureModelOptions and check if it improves results. However, if I remember correctly, the logarithm mode doesn't support different sample weights; so if you need that functionality perhaps it wouldn't work in your case.

As a last option, you could try setting Robust back to false and specify a regularization threshold through the Regularization property of the NormalOptions object. Perhaps a suitable value for initial testings would be 1e-5.

Hope it helps!

Best regards,
Cesar

jamieol...@gmail.com

unread,
Feb 9, 2014, 4:54:55 PM2/9/14
to accor...@googlegroups.com
hi,
thanks! I tried it now with this configuration:

gmm.Compute(melFrequencies, new GaussianMixtureModelOptions()
{
//Weights = weights

Logarithm = true,
NormalOptions = new NormalOptions()
{
Regularization = 1e-1,
Robust = false
}
});

That seems to work a bit better.

One thing that I still think is strange. Maybe you can help me to understand this better. Kmeans and GMM both give me classifications. Although I defined the number of clusters (11) the only computed the values are 1-7 or 8 that can be found in the classifications array can be found.

Any clue why?

Thanks for leading me through this lines of code :)

César

unread,
Feb 10, 2014, 5:51:34 AM2/10/14
to accor...@googlegroups.com
Hi there,

It is mostly likely because some Gaussians clashed into the same cluster during estimation (i.e. some of the identified clusters have the same mean and variance). It could be an indication that the number of Gaussian clusters are around 8, rather than 11, so perhaps decreasing the number of clusters would be a good idea. The problem is that the Gaussian clustering is sometimes difficult to get working, specially for high dimensions, with the current Expectation-Maximization algorithm. As a last note, I just wanted to note that, in case all you need is to obtain codewords or other similar discrete structure from your multivariate continuous data, perhaps a KMeans or a BinarySplit clustering would also work quite well, and not be as tricky to configure.

Hope it helps!

Cesar

jamieol...@gmail.com

unread,
Feb 11, 2014, 8:35:23 AM2/11/14
to accor...@googlegroups.com
Hi César,

thanks for your help. :) I am really happy. You were right with your assumption that some of the clusters have the same mean and variance.
Reply all
Reply to author
Forward
0 new messages