Tuesday 20 May 2014

How To WorkOut Navie Bayes Algorithm

A Naive Bayes Classifier is a simple probabilistic classifier based on applying Bayes' theorem with strong (naive) independence assumptions.The main advantage of naive Bayes is that it only requires a smaller amount of data for training inorder to estimate the class labels necessary for classification. Because independent variables are assumed.

In general all of Machine Learning Algorithms need to be trained for supervised learning tasks like classification, prediction etc. 

By training it means to train them on particular inputs so that later on we may test them for unknown inputs (which they have never seen before) for which they may classify or predict etc (in case of supervised learning) based on their learning. This is what most of the Machine Learning techniques like Neural Networks, SVM, Bayesian etc. are based upon. 

How to Apply NaiveBayes to Predict an Outcome
Let's try it out using an example.



In the above training data we have 2 class labels buys_computer No and Yes. And we know 4 characteristics.


1. Whether the age is youth,middle_aged or senior.
2. Whether income is high,low or medium.
3. Whether they have student or not.
4. Whether credit is excellent,fair.


There are many things to pre-compute from the training dataset for future prediction.


Prior Probabilities

Prior Probabilities
-------------------

P(yes) = 9/14 = 0.643
  Given that the class label is "yes" the universe is 14 = yes(9) + no(5). 9 of them is yes
P(no) = 5/14 = 0.357
  Given that the class label is "no" the universe is 14 = yes(9) + no(5). 5 of them is no

Probability of Likelihood

Probability of Likelihood
-------------------------

P(youth/yes) = 2/9 = 0.222
  Given that the class label is "yes" the universe is 9. 2 of them are youth.
P(youth/no) = 3/5 = 0.600
...
...
P(fair/yes) = 6/9 = 0.667
P(fair/no) = 2/5 = 0.400

How to classify an outcome



Let's say we are given the properties of an unknown buys_computer (class). We are told that the properties are


X => age = youth, income = medium, student = yes, credit rating = fair

We need to 

 Maximize P(X|Ci )P(Ci ), for i = 1, 2

P(Ci ) - the prior probability of each class, can be computed based on the training tuples:



P(yes/youth,medium,yes and fair) 
      = P(youth/yes)* P(medium/yes)* P(yes/yes)* P(fair/yes) * P(yes)
      = (0.222* 0.444* 0.667* 0.667) * 0.643
      = 0.028

P(no/youth,income,medium,yes and fair) 
      = P(youth/no)* P(medium/no)* P(yes/no)* P(fair/no) * P(no)
      = (0.600* 0.400* 0.200* 0.400) * 0.357
      = 0.007

(0.028 >> 0.007), we classify this youth/medium/yes/fair  as likely to be yes.


Therefore, the naive Bayesian classifier predicts buys_computer = yes for tuple X.


16 comments:

  1. Digital Marketing For Forex Broker . We are a Digital Marketing agency focusing on Digital Marketing For Forex Broker. We have been on top of Google search for the phrases you can see on the right and we will be happy to tell you how we did it.

    ReplyDelete
  2. No One Knows How Many Links Are Required To Rank On The First Page Of Google, But It's Safe To Say That There Are A Lot. We Will Do All The Work For You, Including The Tedious Best Seo Company For Forex Process, For A Reasonable Price. We'll Make Sure That You Have A Complete List Of Links, Both Old And New, To Keep Your Site's Rankings High.

    ReplyDelete
  3. We are a service provider with expertise in providing complete information on Harris Teeter Ess . Our team has the resources you need to trade intelligently and improve your knowledge base. Check out our special reports page to get key information on this stock as well as other stocks that may be of interest to you.

    ReplyDelete
  4. The most comprehensive guide to Forex Brokers and Forex Trading Cost , showing you what you can save or earn by choosing the best broker for your needs – from Highest to Lowest Charges. Useful for both beginner and seasoned trader.

    ReplyDelete
  5. If you are looking to find the best place where to buy Where To Buy Ubx Coin , you have come to the right place. Ubx Coin has received a lot of attention lately because 1 coin = $1.00 USD. Because of this, we felt it was necessary to put together a guide that offers you information about UBX and ways that you can buy it.

    ReplyDelete
  6. Truff Stock Get free stock market quotes, stock information, company news, historical charts and financial overviews from Truff Stock . We bring you all the latest Truff Stock market & financial news All in one place.

    ReplyDelete
  7. Attention Cctl Stock Investors! Get All Of Your Favorite Stocks Details In One Place. Stay Ahead Of The Market With Our Live, Real Time Stock Market Overview. Don't Get Left In The Dark Again.

    ReplyDelete
  8. Are you looking to make money by trading currencies on the forex market? Do you want to find the best forex brokers with the lowest costs and fees? Our free guide provides all the information you need to start trading, selecting a reputable and safe broker, and understanding your How To Start A Forex Broker .

    ReplyDelete
  9. Bfarf stock Overview: Stay ahead of the market with our live and real time stock market overview. Get all of your favorite stocks in one place, and get alerted to live news at the same time!

    ReplyDelete
  10. Mmatf Stock Real-Time Overview Of A Stock, Including Recent And Historical Price Charts, News, Events, Analyst Rating Changes And Other Key Stock Information.

    ReplyDelete
  11. The most comprehensive guide to Forex Brokers and Start Forex Brokerage , showing you what you can save or earn by choosing the best broker for your needs – from Highest to Lowest Charges. Useful for both beginner and seasoned trader.

    ReplyDelete
  12. Ati Testing Login will help you to choose the bestAti Testing Login online account for you. We are committed to providing excellent online recommendation for home buyers and sellers of personal information.

    ReplyDelete
  13. White Label Partnership Forex is an online forex trading course designed for beginner traders to learn basic and advanced techniques of the forex market. The course is divided into 10 modules that cover topics such as risk management and position sizing strategies along with highly profitable algorithmic trading strategies.

    ReplyDelete
  14. At Tradingzy, we can help you learn What Is Liquidity In Cryptocurrency and how to use it. We're a digital marketing agency focusing on SEO for the Forex Brokerage company. We're familiar with Google's updates and how to work with them effectively.

    ReplyDelete
  15. Best Regulated Forex Brokers In Samoa Best Regulated Forex Brokers For Your Forex Trading And Fx.The Profanity Review And Forex Today Reviews The Regulated Forex Brokers And Provides The Best Fx Ratings And Reviews.

    ReplyDelete
  16. Would You Like To Access Your CMC Markets Review Account And Manage Your Trades? This Is The Place For You. Here You Can Easily Manage Your Investments, Deposit Or Withdraw Funds. Read More Here.

    ReplyDelete