numpy - Initialize Parameters Gaussian Mixture in Python with sklearn -
i'm trying hard gaussian mixture sklearn think i'm missing because definitively doesn't work.
my original datas this:
genotype logratio  strength ab       0.392805  10.625016 aa       1.922468  10.765716 ab       0.22074   10.405445 bb       -0.059783 10.625016   i want gaussian mixture 3 components = 3 genotypes (aa|ab|bb). know weight of each genotype, mean of log ratio each genotype , mean of strength each genotype.
wgts = [0.8,0.19,0.01]  # weight of aa,ab,bb means = [[-0.5,9],[0.5,9],[1.5,9]] # mean(logratio), mean(strenght) aa,ab,bb    i keep columns logratio , strength , create numpy array.
datas = [[  0.392805  10.625016]          [  1.922468  10.765716]          [  0.22074   10.405445]          [ -0.059783   9.798655]]   then tested function gaussianmixture mixture sklearn v0.18 , tried function gaussianmixturemodel sklearn v0.17 (i still don't see difference , don't know 1 use).
gmm = mixture.gmm(n_components=3)  or gmm = mixture.gaussianmixture(n_components=3)  gmm.fit(datas)  colors = ['r' if i==0 else 'b' if i==1 else 'g' in gmm.predict(datas)] ax = plt.gca() ax.scatter(datas[:,0], datas[:,1], c=colors, alpha=0.8) plt.show()   this obtain , result changes every time because initial parameters calculated differently each run
i initialize parameters in gaussianmixture or gmm function don't understand how have formate datas: (
it possible control randomness reproducibility of results explicitly seeding random_state pseudo random number generator.
instead of :
gmm = mixture.gaussianmixture(n_components=3)   do :
gmm = mixture.gaussianmixture(n_components=3, random_state=3)   random_state must int : i've randomly set 3 can choose other integer.
when running multiple times same random_state, same results.
Comments
Post a Comment