Traditional Culture Encyclopedia - Photography major - R data visualization: PCA principal component analysis diagram
R data visualization: PCA principal component analysis diagram
In the first picture, you can see the back of the kettle, but not the front.
The second picture was taken in front, and you can see the spout. This picture can provide the missing information in the first picture, but the handle of the kettle can't be seen.
In the third plan view, you can see the spout and handle, but you can't see the height of the pot.
The fourth picture is what you plan to put in the catalog. The height, top, spout and handle of the kettle are clearly visible.
The design concept of PCA is similar. It can map high-dimensional data sets to low-dimensional space, while retaining as many variables as possible.
Can I make a PCA diagram similar to SIMCA-P with R language?
The answer is yes. Using R language, we can not only make PCA diagrams like SIMCA-P, but also make better-looking diagrams than SIMCA-P, and the upper limit of good-looking only depends on personal aesthetic style.
Principal component analysis chart = scatter chart+confidence ellipse, and the abscissa and ordinate of scatter point correspond to first principal component and the second principal component of PCA.
Next, I want to add a classification color to the scattered points:
The color is added, but how did the ellipse become three?
It turns out that the stat_ellipse function calculates its own confidence interval for each type of data by default. How to calculate only one confidence interval for multi-class samples? Check the help documentation for stat_ellipse:
It turns out that the stat_ellipse function will inherit the aes setting in ggplot by default. If you want stat_ellipse to use its own aes settings, you need to set the parameter inherit.aes to FALSE.
Next, fine-tune the style: customize colors for different categories of samples, add X-axis and Y-axis titles, and add titles:
Comparing the drawing results with SIMCA-P, the scattered points and ellipses are basically the same, but they are more pleasing to the eye ~
Welcome to leave a message for discussion. If this article is helpful to you, it would be better to like it!
[1] mastering machine learning with scikit -learn
[1] R data visualization: horizontal gradient histogram
[2] R data visualization: double coordinate system column chart
[3] R data visualization: box diagram
[4] R data visualization: circular histogram
- Previous article:20 18 when is luotian hongye festival?
- Next article:The diary is between 200 words and 300 words.
- Related articles
- How can I become an online model? What kind of conditions are needed?
- What is the use of macro shooting with iPhone 14 camera? How to enable macro shooting on iPhone 14?
- Elva information
- I just had a physical examination yesterday. I sat in the car for more than 20 hours before the medical examination. I stood on the train and didn't sleep. Hot throat, stuffy nose and poor breathing.
- When is the best time to watch the sunrise in Huashan?
- Zilong's sad subway
- Which work is Lisa's role?
- How many movies are there? What is the approximate content of each movie?
- Where stalls are allowed in Dongyuan County, Heyuan
- I am a bookworm essay