Hi All....! If i have data set like this means... 3626,5000,2918,5000,2353,2334,2642,1730,1687,1695,1717,1744,593,502,493,504,449,431,444,444,429,10 438,498,3626,3629,5000,2918,5000,2640,2334,2639,1696,1687,1695,1717,1744,592,502,493,504,449,431,444,441,429,10 439,498,3626,3629,5000,2918,5000,2633,2334,2645,1705,1686,1694,1719,1744,589,502,493,504,446,431,444,444,430,10 440,5000,3627,3628,5000,2919,3028,2346,2330,2638,1727,1684,1692,1714,1745,588,501,492,504,451,433,446,444,432,10 444,5021,3631,3634,5000,2919,5000,2626,2327,2638,1698,1680,1688,1709,1740,595,500,491,503,453,436,448,444,436,10 451,5025,3635,3639,5000,2920,3027,2620,2323,2632,1706,1673,1681,1703,753,595,499,491,502,457,440,453,454,442,20 458,5022,3640,3644,5000,2922,5000,2346,2321,2628,1688,1666,1674,1696,744,590,496.
How to do PCA on this data? if it is in array how to do that? and also how to use princomp() in PCA? Shall i use the following code for doing PCA on given input? could you tell me? from numpy import mean,cov,double,cumsum,dot,linalg,array,rank from pylab import plot,subplot,axis,stem,show,figure A = array([ [2.4,0.7,2.9,2.2,3.0,2.7,1.6,1.1,1.6,0.9], [2.5,0.5,2.2,1.9,3.1,2.3,2,1,1.5,1.1] ]) M = (A-mean(A.T,axis=1)).T[latent,coeff] = linalg.eig(cov(M)) score = dot(coeff.T,M) return coeff,score,latent princomp(A): coeff, score, latent = princomp(A.T) figure() subplot(121) m = mean(A,axis=1) plot([0, -coeff[0,0]*2]+m[0], [0, -coeff[0,1]*2]+m[1],'--k') plot([0, coeff[1,0]*2]+m[0], [0, coeff[1,1]*2]+m[1],'--k') plot(A[0,:],A[1,:],'ob') # the data axis('equal') subplot(122) plot(score[0,:],score[1,:],'*g') axis('equal') plt.show() Thanks....! Regards, Gayathri.
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor