문제

I'm using the pymix package to solve a mixture model.

        m = mixture.MixtureModel(3,[0.1,0.8,0.1], [n1,n2,n3])

        # Resolver el Mixture model

        m.EM(data,100,0.1)

I cant afterwards do a

        print m

and I can see the final means and std's for a mixture of 3 gaussians. The problem is that I want to access these means and std's to to some computations with them but have no idea how to do so, m.EM() returns a tuple of posterior matrix and log-likelihood from the last iteration but apparently not these means and standard deviations, is there something im missing here? Thank you in advanced.

도움이 되었습니까?

해결책

I know nothing of PyMix, but print m calls m.__str__(), and the source code is readily available for you to see where each value comes from.

다른 팁

I figured out how to extract the mean and stdev by:

x1 = str(m.components[index])
x2 = x1[26:-2].split(",")
mean, stdev = list(map(float,x2))

My x1 grabs the 'ProductDist: \n Normal: [mean, stdev]\n' which prints when you 'print m'. The x2 grabs the 'mean, stdev' into an array, and the last line maps the string versions of the mean and the stdev to floats.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top