-->
当前位置:首页 > 题库

PROGRAMMING:Principal component analysis based on correlation matrix is realized and relevant parameters are output

Luz5年前 (2021-05-10)题库521
There are various kinds of noodle soup in a noodle shop. In order to know the popularity of noodle soup, three dimensions of noodle, soup and ingredients were scored.
![ QQ screenshot 20210101153405. PNG] (~ / edeb7a7e-be58-46f2-b69a-4cd654088f0d. PNG)
Principal component analysis (PCA) is used to mine data: 1) to solve the correlation matrix of data; ② Principal component analysis (PCA) based on correlation matrix is used to solve the eigenvalues of correlation matrix; ③ The correlation coefficient between output surface and soup; The variance contribution rate of the first principal component and the second principal component, as well as their cumulative variance contribution rate.
###Input format:
In the first line, enter all the variable values (separated by spaces in the middle), for example: 2 1 5 2 3 4 4 4 1 3 5 4 5 3 2 5 3 4 2 3 3 3 5 1 4 3 5 2 3 1 2 3.
In the second line, enter the number of samples and variables (separated by spaces), for example: 103.
###Output format:
The correlation coefficient between output surface and soup; The variance contribution rate of the first principal component and the second principal component, as well as their cumulative variance contribution rate.
###Input example:
```in
2 1 5 2 3 4 4 1 3 5 4 5 3 2 5 3 4 2 3 5 5 1 4 3 5 2 3 1 2 3
10 3
```
```in
2 1 5 2 3 4 4 1 3 5 4 5 3 2 5 3 4 2 3 5 5 1 4 3 5 2 3 1 2 3
15 2
```
###Output example:
```out
The correlation coefficient was - 0.01.
The variance contribution rate of the first principal component is 37.52%, the variance contribution rate of the second principal component is 33.56%, and the cumulative contribution rate of the first two principal components is 71.08%.
```
```out
The correlation coefficient was - 0.17.
The variance contribution rate of the first principal component is 58.36%, the variance contribution rate of the second principal component is 41.64%, and the cumulative contribution rate of the first two principal components is 100.00%.
```






answer:If there is no answer, please comment