In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
How to understand the linear discriminant analysis in R language classification algorithm? in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
1. Analysis of Linear Discriminant principle
The basic idea is "projection", that is, the point in the high latitude space is projected to the low latitude space, so as to simplify the treatment of the problem. In the original coordinate system, the points in space may be difficult to be separated, as shown in figure 8-1. When the sample points in category Ⅰ and category Ⅱ are projected to the "original axis" in the diagram, the "shadows" of some sample points coincide, so it is impossible to distinguish the sample points belonging to these two categories. If the projection axis as shown in figure 8-2 is used for projection, the resulting shadow can be clearly distinguished by the category line.
The most important thing for Fisher's discrimination is to select the appropriate projection axis. the requirement for the direction of the projection axis is to ensure that the intra-class distance formed by the projection values in each category is as small as possible, while the distance difference between classes formed by the projection values between different classes is as large as possible.
For linear discrimination, lines project sample points to one-dimensional space, that is, straight lines, if the effect is not obvious, we can consider adding a latitude, that is, projection to two-dimensional space, and so on.
The difference between quadratic discriminant (Quadratic Discriminant Analysis,QDA) and linear discriminant (Linear Discriminant Analysis,LDA) is that the shape of the projection surface is different. Quadratic discrimination uses several Quadric surfaces instead of straight lines or planes to divide the samples into the corresponding categories. Quadratic discriminant function is a commonly used nonlinear discriminant function.
two。 Application in R language
MASS package is the abbreviation of Modern Applied Statistics with S, that is, the application of S language in modern statistics. Linear discriminant analysis (LDA) mainly uses lda (formula,data, … , subset,na.action) function, quadratic discriminant analysis (QDA) uses qda (formula,data,... , subset,na.action) function.
3. Linear Discriminant Analysis based on iris dataset
1) apply the model and view the corresponding parameters of the model
Library (MASS) fit_lda1=lda (Species~.,data_train) fit_lda1
2) View the output of the model
Fit_ LDA1 [1: length (fit_lda1)]
3) make a model diagram
Plot (fit_lda1)
Plot (fit_lda1,dimen=1)
4) predict the data_test and observe the prediction results
Pre_ldal=predict (fit_lda1,data_test) pre_ Ltd [1: length (pre_ldal)]
5) Evaluation and prediction results
Table (data_test$Species,pre_ldal$class) error_lda1=sum (as.numeric (as.numeric (pre_ldal$class)! = as.numeric (data_test$Species)) / nrow (data_test)
This is the answer to the question about how to understand the linear discriminant analysis in the R language classification algorithm. I hope the above content can be of some help to you, if you still have a lot of doubts to be solved. You can follow the industry information channel for more related knowledge.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.