In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article shows you how to understand the naive Bayesian classification in the R language classification algorithm, the content is concise and easy to understand, it can definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
1. Analysis of the principle of naive Bayesian Classification
According to the known prior probability P (A | B), a posteriori probability P (B | A) is obtained by using Bayesian formula P (B | A) = P (A | B) P (B) / P (A), that is, the probability that the sample belongs to a certain class, and then the class with the maximum a posteriori probability is selected as the class to which the sample belongs.
That is to say, for the given sample to be classified, if we find out the probability of each category under the condition of the occurrence of the sample, which one is the largest, the sample is considered to belong to which category.
Its advantage is that it is not afraid of noise and independent variables, and its disadvantage is that it assumes that each feature attribute is irrelevant, which is often not the case in reality.
two。 Application in R language
Naive Bayesian classification mainly uses the NaiveBayes (formula,data,...,subset,na,action=na.pass) function in the klaR package.
3. Discriminant analysis with iris dataset as an example
1) apply the model and observe the results
Library (klaR) fit_Bayes1=NaiveBayes (Species~.,data_train) fit_ Bayes 1 [1: length (fit_Bayes1)]
2) make a density curve
Plot (fit_Bayes1)
3) Predictive analysis and evaluation of the model
Pre_Bayes1=predict (fit_Bayes1,data_test) pre_Bayes1
Table (data_test$Species,pre_Bayes1 $class) error_Bayes1=sum (as.numeric (as.numeric (pre_Bayes1 $class)! = as.numeric (data_test$Species) / nrow (data_test); error_Bayes1
The above content is how to understand the naive Bayesian classification in the R language classification algorithm. have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
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.