Re: Discrepancy in PCA values

2015-01-12 Thread Xiangrui Meng
Could you compare V directly and tell us more about the difference you saw? The column of V should be the same subject to signs. For example, the first column of V could be either [0.8, -0.6, 0.0] or [-0.8, 0.6, 0.0]. -Xiangrui On Sat, Jan 10, 2015 at 8:08 PM, Upul Bandara upulband...@gmail.com

Re: Discrepancy in PCA values

2015-01-10 Thread Upul Bandara
Hi Xiangrui, Thanks a lot for you answer. So I fixed my Julia code, also calculated PCA using R as well. R Code: - data - read.csv('/home/upul/Desktop/iris.csv'); X - data[,1:4] pca - prcomp(X, center = TRUE, scale=FALSE) transformed - predict(pca, newdata = X) Julia Code (Fixed)

Re: Discrepancy in PCA values

2015-01-09 Thread Upul Bandara
Hi Xiangrui, Thanks for the reply. Julia code is also using the covariance matrix: (1/n)*X'*X ; Thanks, Upul On Fri, Jan 9, 2015 at 2:11 AM, Xiangrui Meng men...@gmail.com wrote: The Julia code is computing the SVD of the Gram matrix. PCA should be applied to the covariance matrix.

Re: Discrepancy in PCA values

2015-01-09 Thread Xiangrui Meng
You need to subtract mean values to obtain the covariance matrix (http://en.wikipedia.org/wiki/Covariance_matrix). On Fri, Jan 9, 2015 at 6:41 PM, Upul Bandara upulband...@gmail.com wrote: Hi Xiangrui, Thanks for the reply. Julia code is also using the covariance matrix: (1/n)*X'*X ;

Re: Discrepancy in PCA values

2015-01-08 Thread Xiangrui Meng
The Julia code is computing the SVD of the Gram matrix. PCA should be applied to the covariance matrix. -Xiangrui On Thu, Jan 8, 2015 at 8:27 AM, Upul Bandara upulband...@gmail.com wrote: Hi All, I tried to do PCA for the Iris dataset [https://archive.ics.uci.edu/ml/datasets/Iris] using MLLib