Naive Bayes of classification algorithm-simple Weather Forecasting Algorithm

Source: Internet
Author: User

These two days I learned a relatively simple but very practical classification algorithm-Bayesian classification algorithm. It is indeed more subtle than the SVM algorithm used in my project ,. For example, peat niuwan-delicious and fun, while Bayesian classifier is simple and powerful. This article introduces the simple weather forecast.

Bayesian theorem: Bayesian theorem is a component used to calculate the conditional probability in probability theory! Why is it a sub-device. Calculate the formula first:
At first glance, we can see that this formula is okay, but first we get the formula: P (A | B) P (B) = P (AB ), now I want to swap a with B and find out nothing? A great formula comes:
P (A | B) P (B) = P (AB) = P (B | A) P ()
=>
The core idea of the entire classification algorithm is based on this formula! Why? And look down! What is category: for example, if the weather is divided into simple sunny days and rainy days, then the sunny days and rainy days are classified into one category. So, how to make weather forecasts? It's easy to use some known atmospheric features! To simplify the problem, it is assumed that only the air humidity and cloud layer Density Feature attributes are useful for weather forecasting. The weather forecast is to provide two attribute values: air humidity and cloud layer Density for a day, and output the results of a sunny or rainy day!
Naive Bayes simplifies weather prediction based on the preceding issues:
The simplification of the previous weather forecast seems to be unrelated to the previous formula, but please take a closer look: If H is used to represent humidity, in addition, the humidity levels are 1, 2, and 3, which are H1, H2, and H3 respectively, while the cloud layer density is g, which is also divided into 1, 2, and 3, g1, G2, and G3 are used respectively. In addition, W is used as the weather type, and W1 and W2 are used as the weather type. Then, we can use the previous data to calculate the probability of occurrence of H and G when the result is sunny or rainy (condition), that is, P (H | W), and P (G | W), where H, G, W are within the range of the previously mentioned classification value. If the air humidity H is relatively independent of the cloud layer Density G, then the weather forecast is converted to the following formula: P = P (w | G, H) = P (w | G) XP (w | H:
P = [P (G | W) P (w)/P (g)] x [P (H | W) P (w)/P (h)]

P (G | W) and P (H | W) in the preceding formula indicate the probability of previous statistics, while P (w) indicates the probability that the weather is sunny or rainy, the probability P (W1) and the probability P (W2) of rainy days can be calculated, while P (G) and P (h) are constants for each classification, for example, no matter which type of H is 1, 2, or 3, P (H) is a constant (think about why ?)
Now, we can make predictions!
Probability of days: p1 = P (W1 | G, H) = [P (G | W1) P (W1)/P (g)] x [P (H | W1) P (W1)/P (h)]
Probability of rain:
P2 = P (W2 | G, H) = [P (G | W2) P (W2)/P (g)] x [P (H | W2) P (W2) /P (h)]
The formulas on the right of the equation are known items. For example, if the humidity of a day is H1 and the cloud layer density is G1, the formula above is used to compare the sizes of P1 and P2! In this way, we can easily predict the weather! Conclusion: Bayesian can predict the probability of classification based on the probability statistics of sample data. This can be used in many cases, such as determining whether Weibo users are zombie accounts! Not to mention it.
The general Naive Bayes classification is formally defined as follows:

1. Set it to a feature item to be classified, and each A is a feature attribute of X.

2. There is a set of classes.

3. computing.

Generally, the largest item of P is used as the target classification.

Naive Bayes of classification algorithm-simple Weather Forecasting Algorithm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.