PCA Descending Dimension algorithm

Source: Internet
Author: User

http://ufldl.stanford.edu/wiki/index.php/Principal Component Analysis

If ~exist (' Train_im_all ', ' var ') | | ~exist (' Train_la_all ', ' var ')% to speed up the program so that you do not need to load the data repeatedly when you run this file repeatedly
Load Train_res; % is still the last handwritten digit recognition data, just before the data has been converted to mat file, so you can load data directly with load
End
X0_te= Train_im_all (:, Train_la_all = = 0); % the data to be processed is singled out separately, note that since the data matrix required by the Svmtrain function is a sample value per row, the transpose
X1_te = Train_im_all (:, Train_la_all = = 1);% Ibid.
X2_te = Train_im_all (:, Train_la_all = = 2);% Ibid.
X3_te = Train_im_all (:, Train_la_all = = 3);% Ibid.
X4_te = Train_im_all (:, Train_la_all = = 4);% Ibid.
X5_te = Train_im_all (:, Train_la_all = = 5);% Ibid.
X6_te = Train_im_all (:, Train_la_all = = 6);% Ibid.
X7_te = Train_im_all (:, Train_la_all = = 7);% Ibid.
X8_te = Train_im_all (:, Train_la_all = = 8);% Ibid.
X9_te = Train_im_all (:, Train_la_all = = 9);% Ibid.
Xte={x0_te,x1_te,x2_te,x3_te,x4_te,x5_te,x6_te,x7_te,x8_te,x9_te};
w={};% array of cells to store the reduced-dimension matrix
For I=1:10
Avg = mean (Xte{i}, 2); % for each image pixel strength mean value
D=avg*ones (1,size (xte{i},2));
Xte{i} = xte{i}-D;% de-homogenization
Sigma = xte{i} * xte{i} '/Size (Xte{i}, 2);% to find Signa value
[U,s,v] = SVD (sigma);
%xrot = U ' * x; % of rotated data
Xtilde = U (:, 1:256) ' * xte{i}; % REDUCED-dimensionality data
W=[w,u (:, 1:256) ']; % Select the first 256 eigenvectors (here you can see how many features are better to choose)
End

And then multiply the original sample onto the transformation matrix.

To be refined, because I changed the implementation of the code there, yesterday directly with the tutorial code, training until midnight has not come out, the correct rate is very low

The results are as follows:

So from now until the end of the semester, I don't have to do pattern recognition, write the papers in 23, 59 minutes.

There are several games to do = =

PCA Descending Dimension algorithm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.