← Back to Kurakani

Anyone know abt Matlab and PCA

Original Post

is there anyone that understands how to use matlab and PCA...because i am having probs with project so would be grateful for help recieved thanks

Sram
Apr 26, 2006 6:25 AM · 10,404 views
8 Replies
hyperthread Apr 26, 2006 6:40 AM
whats the problem on? I can try to help you out.
SRAM Apr 26, 2006 7:20 AM
well i have to build an expert system using four variables, in each of these variables there are six columns and 24000 rows and i need to use PCA to reduce the data. the following code only allows me to reduce six rows of one variable at a time, [pn,meanp,stdp] = prestd(p); [ptrans,transMat] = prepca(pn,0.02); do you have any suggestions in reducing the whole amount of data? thanks
hyperthread Apr 26, 2006 7:45 AM
[D,R,T] = dimred(X) X = Original vector data. Each row is a data point. Each column is a dimension in the original space. D = Reduced vector data. Each row is a data point. Each column is a dimension in the lower-dimensional space. R = "rotation" matrix to convert data from the the reduced space back into the original data space . Convert D back to X by using X = D*R+T; T = "translation" matrix The narrowest dimension of the data is compressed to zero. you may wish to compute a dimensionality ratio r such as >>g = svd(X); r = min(g) / max(g); or, g = abs(eig(cov(X))); r = min(g)/max(g); and then proceed if r > To convert some function F of D back to a function G of X in the higher dimnensional space as follows: X = (original data) [D,R,T] = dimred(X); F = (result of some presumably linear operation perfomed on D) G = F*R+T; % C=round(rand(3)*100)/100; % C=C'*C; % [V,D]=eig(C); % D=diag([0 1 2]); % C=V*D*V'; % mu = [4 4 4]; % X=mvnrnd(mu,C,1000); % mu=repmat(mu,[size(X,1) 1]); % % condition inverse of covariance for plots: % D(1,1)=D(2,2)*1e-6; % CI=inv(V*D*V'); % d=sum((X-mu)'.*(CI*(X-mu)')); % X(d>4,:)=[]; % figure % subplot(2,1,1) % hold on % plot3(X(:,1),X(:,2),X(:,3),'b.') % grid on % view(45,10) % axis equal % axis vis3d % [D,R,T]=dimred(X); % k=convhulln(D); % for n=1:length(k) % plot3(X(k(n,:),1),X(k(n,:),2),X(k(n,:),3),'r-','linew',2); % end % title('Original Data (3D)') % subplot(2,1,2) % plot(D(:,1),D(:,2),'b.') % grid on % axis equal % axis tight % title('Transformed Data (2D)') T = repmat(mean(X),[size(X,1),1]); XX = X-T; [R,N]=eig(XX'*XX); D=XX*R; D=D(:,2:end); Q=[zeros(size(D,2),1) eye(size(D,2))]; R=Q*R'; return does that work???
Sram Apr 26, 2006 8:46 AM
Jus to let u kno hyperthread, rather then writing loads of coding here, i have sent u an email abt it
hyperthread Apr 26, 2006 8:52 AM
I will look at it when I wake up later in the evening , will write you back if I think I can help you out.
Thaha_Panyen Apr 26, 2006 10:03 AM
Hyperthread's coding might help. I have little experiences with matlab though I found that everything seems simple to understand and to program, and generally undergrads and grad students with mathematics backgrounds using this software. If you want to do programming for simulation or other purpose (more than just identifying the factor structures of particular data), I think using statistical softwares such as SAS, or SPSS or R/S-Plus is better for PCA as I have some experiences of such analyses using these softwares. It is always better using statistical softwares for statistical analyses as you can find many features on them.
Thaha_Panyen Apr 26, 2006 10:16 AM
sram, you are saying that you want just four varibles (you might be meaning 'four factors') out of six from the data of 24000 subjects or what? PCA gives out important components or factors, not the individual variables. So,for example, if you identified 2 important factors from a possible combinations of 6 variables, these two factors can consist of 2 or more variables. It is not necessarily 4 varibles you want. Might be I understood the problem wrongly.
SRAM Apr 26, 2006 12:29 PM
hhmmm...well i think i should explain the project a little. Its basically predicting if a train is likely to derail from the tracks. So the four variables are linear displacement, vertical displacement, gauge and curvature. And i have been told that i have to use PCA in order to create an expert system.
Login to join the conversation.

You might be interested in...

Recent Classifieds View all
Upcoming Events View all
Service Providers View all
Ask Sajha AI Assistant