pca

PCA Dimension reducion for classification

时光毁灭记忆、已成空白 提交于 2020-01-04 00:42:09
问题 I am using Principle Component Analysis on the features extracted from different layers of CNN. I have downloaded the toolbox of dimension reduction from here. I have a total of 11232 training images and feature for each image is 6532. so the feature matrix is like that 11232x6532 If I want top 90% features I can easily do that and training accuracy using SVM of reduced data is 81.73% which is fair. However, when I try the testing data which have 2408 images and features of each image is 6532

scikit-learn PCA: matrix transformation produces PC estimates with flipped signs

风流意气都作罢 提交于 2020-01-02 04:37:11
问题 I'm using scikit-learn to perform PCA on this dataset. The scikit-learn documentation states that Due to implementation subtleties of the Singular Value Decomposition (SVD), which is used in this implementation, running fit twice on the same matrix can lead to principal components with signs flipped (change in direction). For this reason, it is important to always use the same estimator object to transform data in a consistent fashion. The problem is that I don't think that I'm using

PCA of RGB Image

情到浓时终转凉″ 提交于 2020-01-02 04:34:08
问题 I'm trying to figure out how to use PCA to decorrelate an RGB image in python. I'm using the code found in the O'Reilly Computer vision book: from PIL import Image from numpy import * def pca(X): # Principal Component Analysis # input: X, matrix with training data as flattened arrays in rows # return: projection matrix (with important dimensions first), # variance and mean #get dimensions num_data,dim = X.shape #center data mean_X = X.mean(axis=0) for i in range(num_data): X[i] -= mean_X if

feature extraction using PCA

笑着哭i 提交于 2020-01-01 05:44:24
问题 My job is to perform gesture recognition. I want to do that by training a support vector machine using the features extracted by performing PCA(Principal component Analysis). But I'm getting a little confused about the procedure. After going through various articles, I've figured out these steps. Take 'd' number of images(n*n) of the same gesture. Convert each n*n image into a sigle row. Form a matrix of order d*(n*n). Compute the eigen values & eigen vectors. Use top 'k' eigen vectors to

How to use princomp () function in R when covariance matrix has zero's?

放肆的年华 提交于 2020-01-01 04:36:07
问题 While using princomp() function in R, the following error is encountered : "covariance matrix is not non-negative definite" . I think, this is due to some values being zero (actually close to zero, but becomes zero during rounding) in the covariance matrix. Is there a work around to proceed with PCA when covariance matrix contains zeros ? [FYI : obtaining the covariance matrix is an intermediate step within the princomp() call. Data file to reproduce this error can be downloaded from here -

How to whiten matrix in PCA

人盡茶涼 提交于 2019-12-31 15:45:22
问题 I'm working with Python and I've implemented the PCA using this tutorial. Everything works great, I got the Covariance I did a successful transform, brought it make to the original dimensions not problem. But how do I perform whitening? I tried dividing the eigenvectors by the eigenvalues: S, V = numpy.linalg.eig(cov) V = V / S[:, numpy.newaxis] and used V to transform the data but this led to weird data values. Could someone please shred some light on this? 回答1: Here's a numpy implementation

Obtain eigen values and vectors from sklearn PCA

微笑、不失礼 提交于 2019-12-31 08:09:08
问题 How I can get the the eigen values and eigen vectors of the PCA application? from sklearn.decomposition import PCA clf=PCA(0.98,whiten=True) #converse 98% variance X_train=clf.fit_transform(X_train) X_test=clf.transform(X_test) I can't find it in docs. 1.I am "not" able to comprehend the different results here. Edit : def pca_code(data): #raw_implementation var_per=.98 data-=np.mean(data, axis=0) data/=np.std(data, axis=0) cov_mat=np.cov(data, rowvar=False) evals, evecs = np.linalg.eigh(cov

Obtain eigen values and vectors from sklearn PCA

拥有回忆 提交于 2019-12-31 08:09:07
问题 How I can get the the eigen values and eigen vectors of the PCA application? from sklearn.decomposition import PCA clf=PCA(0.98,whiten=True) #converse 98% variance X_train=clf.fit_transform(X_train) X_test=clf.transform(X_test) I can't find it in docs. 1.I am "not" able to comprehend the different results here. Edit : def pca_code(data): #raw_implementation var_per=.98 data-=np.mean(data, axis=0) data/=np.std(data, axis=0) cov_mat=np.cov(data, rowvar=False) evals, evecs = np.linalg.eigh(cov

Anomaly detection with PCA in Spark

好久不见. 提交于 2019-12-31 03:36:07
问题 I read the following article Anomaly detection with Principal Component Analysis (PCA) In the article is written following: • PCA algorithm basically transforms data readings from an existing coordinate system into a new coordinate system. • The closer data readings are to the center of the new coordinate system, the closer these readings are to an optimum value. • The anomaly score is calculated using the Mahalanobis distance between a reading and the mean of all readings, which is the

Significance of 99% of variance covered by the first component in PCA

半腔热情 提交于 2019-12-31 03:11:21
问题 What does it mean/signify when the first component covers for more than 99% of the total variance in PCA analysis ? I have a feature vector of size 500X1000 on which I used Matlab's pca function which returns [coeff,score,latent,tsquared,explained]. The variable 'explained' returns the percentage of variance covered by each component. 回答1: The explained tells you how accurately you could represent the data by just using that principal component. In your case it means that just using the main