Hi.

I try to reproduce the best fitting plot from
http://www.astroml.org/book_figures/chapter4/fig_GMM_1D.html on my data.

I have sample data, in stead of histogram data.
I have the following code, but get an error because the dimension of my
data is 2.
Could anybody help me with this?

My data looks like this:

1  0
2  0
3  0
4  0
5  0.0411
.....

So in the end I would like to generate a plot with on the xaxis the sample
numbers 1...48, and on the y axis the values.
This plot contains the optimal number gaussian curves from my data

Thanks,

Anna
_____________________________________________________________________

from matplotlib import pyplot as plt
import numpy as np
from sklearn.mixture import GMM

# Create 2D data (first column experiment number, second column values)
vals =
np.array([0,0,0,0,0.0411156712759954,0.0225396968388254,0,0,0,0,0,0.022138290459246,0.0425464266883576,0.0508169878359294,0.0567903916825419,0.0563399686823538,0.0681317778725727,0.0512462144596381,0.0527074396631896,0.0295066808329116,
0.0432790264504283,0.0426921517766538,0.048179363737769,0.0449641383805438,0.0558272813262573,0.0423384372441531,0.0506407929564441,0.0621835447230296,0.0411792604054337,0.0339433473847646,0.0252872771399729,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.0156058321829883])


sample = np.arange(vals.size)
sample += 1

X = np.vstack((sample,vals)).T


# fit models with 1-10 components
N = np.arange(1, 11)
models = [None for i in range(len(N))]

for i in range(len(N)):
    models[i] = GMM(N[i]).fit(X)

# compute the AIC and the BIC
AIC = [m.aic(X) for m in models]
BIC = [m.bic(X) for m in models]

# Find the best fitting with lowest AIC
M_best = models[np.argmin(AIC)]

x = sample
logprob, responsibilities = M_best.eval(x)

And here i get the error: ValueError: The shape of X  is not compatible
with self
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
Scikit-learn-general mailing list
Scikit-learn-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

Reply via email to