当前位置:网站首页>Matlab tips (19) matrix analysis -- principal component analysis
Matlab tips (19) matrix analysis -- principal component analysis
2022-06-27 08:23:00 【mozun2020】
MATLAB Tips (19) matrix analysis -- Principal component analysis
Preface
MATLAB Learning about image processing is very friendly , You can start from scratch , There are many encapsulated functions that can be called directly for basic image processing , This series of articles is mainly to introduce some of you in MATLAB Some concept functions are commonly used in routine demonstration !
Principal component analysis (Principal Component Analysis,PCA), It's a statistical method . Through orthogonal transformation, a set of variables that may be correlated are transformed into a set of linear uncorrelated variables , The transformed set of variables is called principal component . In practical subjects , In order to comprehensively analyze the problem , Many variables related to this are often proposed ( Or factors ), Because each variable reflects some information of this subject to varying degrees . The principal component analysis (PCA) is first performed by K. Pearson (Karl Pearson) For non random variables , Later H. Hotelling extended this method to the case of random vectors . The size of information is usually measured in terms of sum of squares of deviation or variance .
The main steps of principal component analysis are as follows :
Standardization of indicator data (SPSS Software automatic execution );
Determination of correlation between indicators ;
Determine the number of principal components m;
The principal components Fi expression ;
The principal components Fi name .
Principal component analysis is a statistical method of dimension reduction , It relies on an orthogonal transformation , The original random vector whose components are related is transformed into a new random vector whose components are not related , This is expressed algebraically by transforming the covariance matrix of the original random vector into a diagonal matrix , Geometrically, it is expressed as transforming the original coordinate system into a new orthogonal coordinate system , Make it point to the sample point with the most open distribution p Two orthogonal directions , Then, the multidimensional variable system is reduced , So that it can be transformed into a low dimensional variable system with a high precision , And then by constructing an appropriate value function , Further transform the low dimensional system into one dimensional system .
The example encountered when searching for data , Here to share ,MATLAB Version is MATLAB2015b.
One . MATLAB Simulation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% function : matrix analysis -- Principal component analysis
% Environmental Science :Win7,Matlab2015b
%Modi: C.S
% Time :2022-06-25
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Clear environment variables
clear all
clc
tic
A=[1 1/5 1 1/5 1/6 1/6
5 1 5 1/2 1/2 1/2
2 1/5 1 1/4 1/6 1/4
5 1/2 4 1 1/2 1/2
6 2 6 2 1 1
6 2 4 2 1 1];
h=zscore(A); % Data standardization
r=corrcoef(h); % Calculate the correlation coefficient matrix
disp(' The calculated correlation coefficient matrix is as follows :');
disp(r);
[x,y,z]=pcacov(r); % Calculate eigenvectors and eigenvalues
s=zeros(size(z));
for i=1:length(z)
s(i)=sum(z(1:i));
end
disp(' The first several eigenvalues of the correlation coefficient matrix and their contribution rates are calculated from the above :');
disp([z,s])
tg=[z,s];
f=repmat(sign(sum(x)),size(x,1),1);
x=x.*f;
n=input(' Please select before n The principal components to be calculated :\n');
disp(' The selected principal component coefficients are :');
for i=1:n
xs(i,:)=(x(:,i)');
end
newdt=h*xs';
disp(' Take the contribution rate of the principal components as the weight , Construct the coefficient of principal component comprehensive evaluation model :');
q=((z(1:n)./100)')
w=input(' Whether the principal component comprehensive evaluation is required ?(y or n)\n');
if w==y
df=h*x(:,1:n);
tf=df*z(1:n)/100;
[stf,ind]=sort(tf,'descend'); % In descending order
disp(' Ranking of comprehensive evaluation results of principal components :');
px=[ind,stf]
else
return;
end
toc
Two . Simulation results
The calculated correlation coefficient matrix is as follows :
1.0000 0.8374 0.9252 0.8344 0.9009 0.8941
0.8374 1.0000 0.7750 0.9281 0.9766 0.9771
0.9252 0.7750 1.0000 0.7110 0.8141 0.7946
0.8344 0.9281 0.7110 1.0000 0.9749 0.9771
0.9009 0.9766 0.8141 0.9749 1.0000 0.9967
0.8941 0.9771 0.7946 0.9771 0.9967 1.0000
The first several eigenvalues of the correlation coefficient matrix and their contribution rates are calculated from the above :
90.7979 90.7979
7.0303 97.8282
1.4832 99.3114
0.6456 99.9569
0.0431 100.0000
0.0000 100.0000
Please select before n The principal components to be calculated :
4
The selected principal component coefficients are :
Take the contribution rate of the principal components as the weight , Construct the coefficient of principal component comprehensive evaluation model :
q =
0.9080 0.0703 0.0148 0.0065
Whether the principal component comprehensive evaluation is required ?(y or n)
y
Ranking of comprehensive evaluation results of principal components :
px =
5.0000 2.5471
6.0000 2.1629
2.0000 0.1177
4.0000 -0.0866
3.0000 -2.2277
1.0000 -2.5134
Time has passed 13.348336 second .
3、 ... and . Summary
Examples of matrix principal component analysis methods , I remember learning this before , My understanding is , It can be applied when processing characteristic parameters , The main application scenario is also the dimensionality reduction of data , When information becomes redundant , It will also interfere with the application of prediction and identification , Therefore, it is necessary to filter and adjust the redundant information , And by PCA Dimension reduction , Keep only the information about the main ingredients , Better classification and prediction results will be obtained , Or because of hardware resources , Without losing actual performance requirements , The system response time can be improved by dimensionality reduction , It's also PCA An application scenario of the method . Actually MATLAB The functions of principal component analysis have been integrated , This is equivalent to rewriting , Take a note . Learn one every day MATLAB Little knowledge , Let's learn and make progress together !
边栏推荐
- Refer to | the computer cannot access the Internet after the hotspot is turned on in win11
- After working in a large factory for ten years with an annual salary of 400000 yuan, I was suddenly laid off. If the company wanted to abandon you, it wouldn't leave any kindness
- 即构「畅直播」,全链路升级的一站式直播服务
- Futures reverse Documentary - training for traders
- Online text digit recognition list summation tool
- [batch dos-cmd command - summary and summary] - parameters%0,%1,%2,%[0-9],%0-9 in the batch command and batch command parameter position switching command shift, operator% usage in the DOS command
- Mysql事务中MVCC理解超简单
- 【10. 差分】
- Helix QAC is updated to 2022.1 and will continue to provide high standard compliance coverage
- 05 observer mode
猜你喜欢
【12. 最大连续不重复子序列】
05 观察者(Observer)模式
After working in a large factory for ten years with an annual salary of 400000 yuan, I was suddenly laid off. If the company wanted to abandon you, it wouldn't leave any kindness
PayPal account has been massively frozen! How can cross-border sellers help themselves?
(原创)自定义Drawable
[10. difference]
游戏资产复用:更快找到所需游戏资产的新方法
Binary tree structure and heap structure foundation
即构「畅直播」,全链路升级的一站式直播服务
Preliminary understanding of C #
随机推荐
lvgl 说明3关于lvgl guider的使用
Code source AQS sous - jacent pour la programmation simultanée juc
盲測調查顯示女碼農比男碼農更優秀
关于el-date-picker点击清空参数变为null的问题
MySQL锁详解
Lvgl usage demo and instructions 2
Analysis log log
Lvgl GUI guide porting code to stm32
University database mysql
Coggle 30 days of ML July competition learning
【每日一练】产品卡片动画效果的实现
Game asset reuse: a new way to find required game assets faster
Read datasets iteratively with xgboost
关于放大器失真的原因你了解多少呢?
【12. 最大连续不重复子序列】
Experience record of Luogu's topic brushing
Recognize the ordering of O (nlogn)
[13. number and bit operation of 1 in binary]
MySQL环境变量配置的教程
How can I import data from Oracle into fastdfs?