so just refresher on bayestheorem -rememberthe probability of given is equal to the overall probability of times the probability of given over the overall probability of bhow can we use that in machine learningi can actually build spam classifier for thatan algorithm that can analyze set of known spam -mails and known set of non-spam emailsand train model to actually predict whether new -mails are spam or not this is real technique used in actual spam classifiers in the real world as an examplelet' just figure out the probability of an -mail being spam given that it contains the word "freeif people are promising you free stuffit' probably spamso let' work that out the probability of an email being spam given that you have the word "freein that -mail works out to the overall probability of it being spam message times the probability of containing the word "freegiven that it' spam over the probability overall of being freethe numerator can just be thought of as the probability of message being qbn and containing the word 'sff but that' little bit different than what we're looking forbecause that' the odds out of the complete dataset and not just the odds within things that contain the word 'sff the denominator is just the overall probability of containing the word 'sff sometimes that won' be immediately accessible to you from the data that you have if it' notyou can expand that out to the following expression if you need to derive itthis gives you the percentage of -mails that contain the word "freethat are spamwhich would be useful thing to know when you're trying to figure out if it' spam or not what about all the other words in the english languagethoughso our spam classifier should know about more than just the word "freeit should automatically pick up every word in the messageideallyand figure out how much does that contribute to the likelihood of particular -mail being spam so what we can do is train our model on every word that we encounter during trainingthrowing out things like "aand "theand "andand meaningless words like that then when we go through all the words in new -mailwe can multiply the probability of being spam for each word togetherand we get the overall probability of that -mail being spam