{"id":2577,"date":"2023-10-29T14:18:00","date_gmt":"2023-10-29T14:18:00","guid":{"rendered":"https:\/\/mlinsightscentral.com\/?page_id=2577"},"modified":"2023-11-24T13:37:52","modified_gmt":"2023-11-24T13:37:52","slug":"naive-bayes-classifier","status":"publish","type":"page","link":"https:\/\/mlinsightscentral.com\/index.php\/naive-bayes-classifier\/","title":{"rendered":"Naive Bayes Classifier"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-page\" data-elementor-id=\"2577\" class=\"elementor elementor-2577\">\n\t\t\t\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-bf403a4 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"bf403a4\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-24cf081\" data-id=\"24cf081\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-bb21dcb elementor-widget elementor-widget-heading\" data-id=\"bb21dcb\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<style>\/*! elementor - v3.13.3 - 28-05-2023 *\/\n.elementor-heading-title{padding:0;margin:0;line-height:1}.elementor-widget-heading .elementor-heading-title[class*=elementor-size-]>a{color:inherit;font-size:inherit;line-height:inherit}.elementor-widget-heading .elementor-heading-title.elementor-size-small{font-size:15px}.elementor-widget-heading .elementor-heading-title.elementor-size-medium{font-size:19px}.elementor-widget-heading .elementor-heading-title.elementor-size-large{font-size:29px}.elementor-widget-heading .elementor-heading-title.elementor-size-xl{font-size:39px}.elementor-widget-heading .elementor-heading-title.elementor-size-xxl{font-size:59px}<\/style><h3 class=\"elementor-heading-title elementor-size-default\"><span class=\"ez-toc-section\" id=\"Naive_Bayes_Classifier\"><\/span>Naive Bayes Classifier<span class=\"ez-toc-section-end\"><\/span><\/h3>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-a2610b2 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"a2610b2\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-296653c\" data-id=\"296653c\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-ec60dcb elementor-widget elementor-widget-text-editor\" data-id=\"ec60dcb\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<style>\/*! elementor - v3.13.3 - 28-05-2023 *\/\n.elementor-widget-text-editor.elementor-drop-cap-view-stacked .elementor-drop-cap{background-color:#69727d;color:#fff}.elementor-widget-text-editor.elementor-drop-cap-view-framed .elementor-drop-cap{color:#69727d;border:3px solid;background-color:transparent}.elementor-widget-text-editor:not(.elementor-drop-cap-view-default) .elementor-drop-cap{margin-top:8px}.elementor-widget-text-editor:not(.elementor-drop-cap-view-default) .elementor-drop-cap-letter{width:1em;height:1em}.elementor-widget-text-editor .elementor-drop-cap{float:left;text-align:center;line-height:1;font-size:50px}.elementor-widget-text-editor .elementor-drop-cap-letter{display:inline-block}<\/style>\t\t\t\t<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_53 ez-toc-wrap-left counter-hierarchy ez-toc-counter ez-toc-light-blue ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title \" >Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\" role=\"button\"><label for=\"item-69e3020c2c3a4\" ><span class=\"\"><span style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input aria-label=\"Toggle\" aria-label=\"item-69e3020c2c3a4\"  type=\"checkbox\" id=\"item-69e3020c2c3a4\"><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/mlinsightscentral.com\/index.php\/naive-bayes-classifier\/#Naive_Bayes_Classifier\" title=\"Naive Bayes Classifier\">Naive Bayes Classifier<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/mlinsightscentral.com\/index.php\/naive-bayes-classifier\/#Deriving_the_Naive_Bayes_algorithm\" title=\"Deriving the Naive Bayes algorithm\">Deriving the Naive Bayes algorithm<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/mlinsightscentral.com\/index.php\/naive-bayes-classifier\/#Python_Implementation\" title=\"Python Implementation\">Python Implementation<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/mlinsightscentral.com\/index.php\/naive-bayes-classifier\/#Conclusion\" title=\"Conclusion\">Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-4dfa3a0 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"4dfa3a0\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-665f41b\" data-id=\"665f41b\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-bb75d8a elementor-widget elementor-widget-image\" data-id=\"bb75d8a\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<style>\/*! elementor - v3.13.3 - 28-05-2023 *\/\n.elementor-widget-image{text-align:center}.elementor-widget-image a{display:inline-block}.elementor-widget-image a img[src$=\".svg\"]{width:48px}.elementor-widget-image img{vertical-align:middle;display:inline-block}<\/style>\t\t\t\t\t\t\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" width=\"768\" height=\"419\" src=\"https:\/\/mlinsightscentral.com\/wp-content\/uploads\/2023\/11\/naive_bayes-768x419.png\" class=\"attachment-medium_large size-medium_large wp-image-2815\" alt=\"\" srcset=\"https:\/\/mlinsightscentral.com\/wp-content\/uploads\/2023\/11\/naive_bayes-768x419.png 768w, https:\/\/mlinsightscentral.com\/wp-content\/uploads\/2023\/11\/naive_bayes-300x164.png 300w, https:\/\/mlinsightscentral.com\/wp-content\/uploads\/2023\/11\/naive_bayes-1024x559.png 1024w, https:\/\/mlinsightscentral.com\/wp-content\/uploads\/2023\/11\/naive_bayes-1536x839.png 1536w, https:\/\/mlinsightscentral.com\/wp-content\/uploads\/2023\/11\/naive_bayes.png 1910w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-7296f8d elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"7296f8d\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-266f357\" data-id=\"266f357\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-dda9699 elementor-widget elementor-widget-text-editor\" data-id=\"dda9699\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>The Naive Bayes classifier is a classification method that takes the assumption of independence in features to relax the Bayes theorem and build a classification method.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-92689a6 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"92689a6\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-eac90bd\" data-id=\"eac90bd\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-de50d6f elementor-widget elementor-widget-text-editor\" data-id=\"de50d6f\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>\\[P(B|A) = \\frac{P(A \\cap B) }{P(A)} = \\frac{P(A|B)P(B)}{P(A)}\\]<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-a2cfcb7 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"a2cfcb7\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-fb93530\" data-id=\"fb93530\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-6c0ce09 elementor-widget elementor-widget-text-editor\" data-id=\"6c0ce09\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>\\[P(Y=k|X=[x_1,x_2,..x_n]) = \\frac{P( x_1 \\cap x_2 ..\\cap\u00a0 x_n \\cap Y=k)}{P(x_1 \\cap x_2 &#8230;\\cap x_n)}\\]<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-ead1164 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"ead1164\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-570e20a\" data-id=\"570e20a\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-f554329 elementor-widget elementor-widget-heading\" data-id=\"f554329\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\"><span class=\"ez-toc-section\" id=\"Deriving_the_Naive_Bayes_algorithm\"><\/span>Deriving the Naive Bayes algorithm<span class=\"ez-toc-section-end\"><\/span><\/h3>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-973a385 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"973a385\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-81edb0b\" data-id=\"81edb0b\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-8c6ff16 elementor-widget elementor-widget-text-editor\" data-id=\"8c6ff16\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>The conditional probability P(Y=k, X) can be further developed<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-c2c2429 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"c2c2429\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-68f4206\" data-id=\"68f4206\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-a5db48f elementor-widget elementor-widget-text-editor\" data-id=\"a5db48f\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>\\[P(Y=k|X=[x_1,x_2,..x_n]) = \\frac{P( x_1 \\cap x_2 ..\\cap\u00a0 x_n \\cap Y=k)}{P(x_1 \\cap x_2 &#8230;\\cap x_n)} = \\frac{P(x_1|x_2,x_3..x_n,Y=k)P(x_2 ..\\cap\u00a0 x_n \\cap Y=k)}{P(x_1 \\cap x_2 &#8230;\\cap x_n)}\\]<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-8eb3768 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"8eb3768\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-48aff48\" data-id=\"48aff48\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-9389770 elementor-widget elementor-widget-text-editor\" data-id=\"9389770\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>\\[P(Y=k|x_1,x_2,..x_n) = \\frac{P(x_1|x_2,x_3..x_n,Y=k)P(x_2 ..\\cap\u00a0 x_n \\cap Y=k)}{P(x_1 \\cap x_2 &#8230;\\cap x_n)} =\u00a0 \\frac{P(x_1|x_2,x_3..x_n,Y=k)P(x_2|x_3&#8230;x_n,Y=k)P(x_3 ..\\cap\u00a0 x_n \\cap Y=k)}{P(x_1 \\cap x_2 &#8230;\\cap x_n)}\u00a0\\]<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-e3cd898 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"e3cd898\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-83e861d\" data-id=\"83e861d\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-06079f6 elementor-widget elementor-widget-text-editor\" data-id=\"06079f6\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>\\[P(Y=k|x_1,x_2,..x_n)\u00a0 \u00a0= \\frac{P(x_1|x_2,x_3..x_n,Y=k)P(x_2|x_3&#8230;x_n,Y=k)P(x_3 |..\u00a0 x_n, Y=k)P( .. x_n, Y=k)}{P(x_1 \\cap x_2 &#8230;\\cap x_n)}\\]<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-43413be elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"43413be\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-1ba590d\" data-id=\"1ba590d\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-94f8419 elementor-widget elementor-widget-text-editor\" data-id=\"94f8419\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>\\[P(Y=k|x_1,x_2,..x_n)\u00a0 \u00a0=..=\\frac{P(x_1|x_2,x_3..x_n,Y=k)P(x_2|x_3&#8230;x_n,Y=k)P(x_3 |..\u00a0 x_n, Y=k)&#8230;P(x_n| Y=k)P(Y=k)}{P(x_1 \\cap x_2 &#8230;\\cap x_n)}\\]<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-6a32e2b elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"6a32e2b\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-28156e8\" data-id=\"28156e8\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-5c008d2 elementor-widget elementor-widget-text-editor\" data-id=\"5c008d2\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>The <strong>first assumption<\/strong> of the Naive Bayes algorithm is conditional independence in feature:\u00a0<\/p><p>\\[P(x_i|Y=k, x_j) = P (x_i|Y=k) \\]<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-403b9e9 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"403b9e9\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-edf8d98\" data-id=\"edf8d98\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-23fadb0 elementor-widget elementor-widget-text-editor\" data-id=\"23fadb0\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>This assumption leads to the following relaxation of the Bayes Theorem:<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-96cd03d elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"96cd03d\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-2d84d20\" data-id=\"2d84d20\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-0a2e998 elementor-widget elementor-widget-text-editor\" data-id=\"0a2e998\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>\\[P(Y=k|x_1,x_2,..x_n)\u00a0 =\\frac{P(x_1|Y=k)P(x_2|Y=k)P(x_3 |Y=k)&#8230;P(x_n| Y=k)P(Y=k)}{P(x_1 \\cap x_2 &#8230;\\cap x_n)}\\]<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-a1bcd84 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"a1bcd84\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-06ad19c\" data-id=\"06ad19c\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-f118903 elementor-widget elementor-widget-text-editor\" data-id=\"f118903\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>This relaxation drastically simplifies the computation of the conditional probability P(Y|X) which now only depends on the conditional probabilities P(x_i|Y=k) and the joint probability of features.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-5058db4 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"5058db4\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-c05c9ea\" data-id=\"c05c9ea\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-628ffb2 elementor-widget elementor-widget-text-editor\" data-id=\"628ffb2\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>The <strong>second simplification<\/strong> of the Naive Bayes theorem is to disregard the joint probability of features P(x_1,x_2,..x_n) as this probability is a constant and equally comparable when assessing a given vector belongingness among each class k.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-1ed2c64 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"1ed2c64\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-8a7bf51\" data-id=\"8a7bf51\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-2379edf elementor-widget elementor-widget-text-editor\" data-id=\"2379edf\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>\\[P(Y=k|x_1,x_2,..x_n) \\text{ } \\alpha\\text{ } P(x_1|Y=k)P(x_2|Y=k)P(x_3 |Y=k)&#8230;P(x_n| Y=k)P(Y=k)\\]<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-6ae01d6 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"6ae01d6\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-6ab1af0\" data-id=\"6ab1af0\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-0dfb7f5 elementor-widget elementor-widget-text-editor\" data-id=\"0dfb7f5\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>Thus the Naive Bayes classifier does not compute true probability but rather a probability-based score to assign a data point to the most probable class.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-7ddb4b6 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"7ddb4b6\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-294fe1a\" data-id=\"294fe1a\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-c045f00 elementor-widget elementor-widget-text-editor\" data-id=\"c045f00\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>\\[\\text{Naive Bayes Score }(Y=k|x_1,x_2,..x_n) = P(x_1|Y=k)P(x_2|Y=k)P(x_3 |Y=k)&#8230;P(x_n| Y=k)P(Y=k)\\]<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-913b942 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"913b942\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-d82bfab\" data-id=\"d82bfab\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-0dd03f5 elementor-widget elementor-widget-text-editor\" data-id=\"0dd03f5\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>For a generic implementation of the classifier, the conditional probabilities P(x_i|Y=k) are estimated from the data using probability density functions, most commonly estimated to be normal (<strong>Gaussian Naive Bayes<\/strong>) or using kernel density functions (<b>Kernel Naive Bayes<\/b>) for more accurate results.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-2a219c6 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"2a219c6\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-94669d7\" data-id=\"94669d7\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-13ebc2e elementor-widget elementor-widget-heading\" data-id=\"13ebc2e\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\"><span class=\"ez-toc-section\" id=\"Python_Implementation\"><\/span>Python Implementation<span class=\"ez-toc-section-end\"><\/span><\/h3>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-6577e54 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"6577e54\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-59a7b28\" data-id=\"59a7b28\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-bbf67e9 elementor-widget elementor-widget-text-editor\" data-id=\"bbf67e9\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>\u00a0A sample dataset for diabetes classification [1] will be used to test the performance of kNN as a binary classifier.\u00a0 Data were extracted from 2768 patient records with mixed data of healthy and non-healthy patients inclusive of nine attributes:<\/p><ol><li><strong>Id:<\/strong>\u00a0Unique identifier for each data entry.<\/li><li><strong>Pregnancies:<\/strong>\u00a0Number of times pregnant.<\/li><li><strong>Glucose:<\/strong>\u00a0Plasma glucose concentration over 2 hours in an oral glucose tolerance test.<\/li><li><strong>BloodPressure:<\/strong>\u00a0Diastolic blood pressure (mm Hg).<\/li><li><strong>SkinThickness:<\/strong>\u00a0Triceps skinfold thickness (mm).<\/li><li><strong>Insulin:<\/strong>\u00a02-Hour serum insulin (mu U\/ml).<\/li><li><strong>BMI:<\/strong>\u00a0Body mass index (weight in kg \/ height in m^2).<\/li><li><strong>DiabetesPedigreeFunction:<\/strong>\u00a0Diabetes pedigree function, a genetic score of diabetes.<\/li><li><strong>Age:<\/strong>\u00a0Age in years.<\/li><li><strong>Outcome:<\/strong>\u00a0Binary classification indicating the presence (1) or absence (0) of diabetes.<\/li><\/ol>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-3f0f9cd elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"3f0f9cd\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-bb1c117\" data-id=\"bb1c117\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-69fe2dc elementor-widget elementor-widget-image\" data-id=\"69fe2dc\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" width=\"825\" height=\"179\" src=\"https:\/\/mlinsightscentral.com\/wp-content\/uploads\/2023\/09\/diabetes_datasets.png\" class=\"attachment-large size-large wp-image-1733\" alt=\"diabetes datasets\" srcset=\"https:\/\/mlinsightscentral.com\/wp-content\/uploads\/2023\/09\/diabetes_datasets.png 825w, https:\/\/mlinsightscentral.com\/wp-content\/uploads\/2023\/09\/diabetes_datasets-300x65.png 300w, https:\/\/mlinsightscentral.com\/wp-content\/uploads\/2023\/09\/diabetes_datasets-768x167.png 768w\" sizes=\"auto, (max-width: 825px) 100vw, 825px\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-0402c13 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"0402c13\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-d6a4d88\" data-id=\"d6a4d88\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-3191c45 elementor-widget elementor-widget-text-editor\" data-id=\"3191c45\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>The dataset of records is split into training and test (80\/20) to test the predictive performance of the Naive Bayes classifier in distinguishing between the presence or absence of diabetes. The model will thus be trained on the training set alone but benchmarked on the training and test set. The test performance is the most important as it indicates the model&#8217;s predictive power on unseen data.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-6995ea5 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"6995ea5\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-d74ab2f\" data-id=\"d74ab2f\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-2d05614 elementor-widget elementor-widget-elementor-syntax-highlighter\" data-id=\"2d05614\" data-element_type=\"widget\" data-widget_type=\"elementor-syntax-highlighter.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<pre><code class='language-python'>import pandas as pd\nimport warnings\nwarnings.filterwarnings('ignore') #ignore warnings\ndf = pd.read_csv('https:\/\/raw.githubusercontent.com\/mlinsights\/freemium\/main\/datasets\/classification\/diabetes\/Healthcare-Diabetes.csv')\n\n\nX = df.iloc[:,1:9]\ny = df[['Outcome']]\n\nfrom sklearn.model_selection import train_test_split\n\nX_train, X_test, y_train, y_test = train_test_split(X,y,test_size=0.2,random_state=1234)#fix the random seed (to reproduce the results)\n\n\nfrom sklearn.naive_bayes import GaussianNB\n\nclf = GaussianNB()\nclf.fit(X_train,y_train)#train the classifier\n#get model prediction on train set and test set\ny_pred_train = clf.predict(X_train)\ny_pred_test = clf.predict(X_test)\n\n\nfrom sklearn.metrics import confusion_matrix\nfrom sklearn.metrics import classification_report\n\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nimport numpy as np\n\n# Create confusion matrix for the training set\ncm_train = confusion_matrix(y_train, y_pred_train)\n\n# Create heatmap - Test set\nplt.figure(figsize=(8, 6))\nsns.set(font_scale=1.2)\nsns.heatmap(cm_train, annot=True, fmt=&quot;d&quot;, cmap=&quot;Blues&quot;, cbar=False, square=True)\nplt.xlabel('Predicted')\nplt.ylabel('Actual')\nplt.title('Confusion Matrix - Train')\nplt.show()\n\ntrain_report = classification_report(y_train, y_pred_train, target_names=['has diabetes','no diabetes'])\nprint(&quot;Classification Report:\\n&quot;, train_report)\n\n\n# Create confusion matrix test set\ncm_test = confusion_matrix(y_test, y_pred_test)\n# Create heatmap - Test set\nplt.figure(figsize=(8, 6))\nsns.set(font_scale=1.2)\nsns.heatmap(cm_test, annot=True, fmt=&quot;d&quot;, cmap=&quot;Blues&quot;, cbar=False, square=True)\nplt.xlabel('Predicted')\nplt.ylabel('Actual')\nplt.title('Confusion Matrix - Test')\nplt.show()\n\n#tn, fp, fn, tp = cm_test\nclass_acc = (cm_test[0][0]+cm_test[1][1])\/(cm_test[0][0]+cm_test[0][1]+cm_test[1][0]+cm_test[1][1])\ntest_report = classification_report(y_test, y_pred_test, target_names=['has diabetes','no diabetes'])\nprint(&quot;Classification Report:\\n&quot;, test_report)\n\n <\/code><\/pre><script>\nif (!document.getElementById('syntaxed-prism')) {\n\tvar my_awesome_script = document.createElement('script');\n\tmy_awesome_script.setAttribute('src','https:\/\/mlinsightscentral.com\/wp-content\/plugins\/syntax-highlighter-for-elementor\/assets\/prism2.js');\n\tmy_awesome_script.setAttribute('id','syntaxed-prism');\n\tdocument.body.appendChild(my_awesome_script);\n} else {\n\twindow.Prism && Prism.highlightAll();\n}\n<\/script>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-e4d8006 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"e4d8006\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-50 elementor-top-column elementor-element elementor-element-29aedad\" data-id=\"29aedad\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-dd00c26 elementor-widget elementor-widget-image\" data-id=\"dd00c26\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" width=\"537\" height=\"561\" src=\"https:\/\/mlinsightscentral.com\/wp-content\/uploads\/2023\/10\/cm_train_nb.png\" class=\"attachment-large size-large wp-image-2773\" alt=\"\" srcset=\"https:\/\/mlinsightscentral.com\/wp-content\/uploads\/2023\/10\/cm_train_nb.png 537w, https:\/\/mlinsightscentral.com\/wp-content\/uploads\/2023\/10\/cm_train_nb-287x300.png 287w\" sizes=\"auto, (max-width: 537px) 100vw, 537px\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t<div class=\"elementor-column elementor-col-50 elementor-top-column elementor-element elementor-element-234ac7f\" data-id=\"234ac7f\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-af4feab elementor-widget elementor-widget-image\" data-id=\"af4feab\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" width=\"537\" height=\"561\" src=\"https:\/\/mlinsightscentral.com\/wp-content\/uploads\/2023\/10\/cm_test_nb.png\" class=\"attachment-large size-large wp-image-2774\" alt=\"\" srcset=\"https:\/\/mlinsightscentral.com\/wp-content\/uploads\/2023\/10\/cm_test_nb.png 537w, https:\/\/mlinsightscentral.com\/wp-content\/uploads\/2023\/10\/cm_test_nb-287x300.png 287w\" sizes=\"auto, (max-width: 537px) 100vw, 537px\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-97a01b0 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"97a01b0\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-50 elementor-top-column elementor-element elementor-element-3c7e1f3\" data-id=\"3c7e1f3\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-e86c1d6 elementor-widget elementor-widget-image\" data-id=\"e86c1d6\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"377\" src=\"https:\/\/mlinsightscentral.com\/wp-content\/uploads\/2023\/10\/classification_report_train_nb-1024x377.png\" class=\"attachment-large size-large wp-image-2778\" alt=\"\" srcset=\"https:\/\/mlinsightscentral.com\/wp-content\/uploads\/2023\/10\/classification_report_train_nb-1024x377.png 1024w, https:\/\/mlinsightscentral.com\/wp-content\/uploads\/2023\/10\/classification_report_train_nb-300x110.png 300w, https:\/\/mlinsightscentral.com\/wp-content\/uploads\/2023\/10\/classification_report_train_nb-768x283.png 768w, https:\/\/mlinsightscentral.com\/wp-content\/uploads\/2023\/10\/classification_report_train_nb.png 1454w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t<div class=\"elementor-column elementor-col-50 elementor-top-column elementor-element elementor-element-b15f7d7\" data-id=\"b15f7d7\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-a05f9a7 elementor-widget elementor-widget-image\" data-id=\"a05f9a7\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"370\" src=\"https:\/\/mlinsightscentral.com\/wp-content\/uploads\/2023\/10\/classification_report_test_nb-1024x370.png\" class=\"attachment-large size-large wp-image-2779\" alt=\"\" srcset=\"https:\/\/mlinsightscentral.com\/wp-content\/uploads\/2023\/10\/classification_report_test_nb-1024x370.png 1024w, https:\/\/mlinsightscentral.com\/wp-content\/uploads\/2023\/10\/classification_report_test_nb-300x108.png 300w, https:\/\/mlinsightscentral.com\/wp-content\/uploads\/2023\/10\/classification_report_test_nb-768x277.png 768w, https:\/\/mlinsightscentral.com\/wp-content\/uploads\/2023\/10\/classification_report_test_nb.png 1418w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-3380993 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"3380993\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-ce79f6b\" data-id=\"ce79f6b\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-34656d5 elementor-widget elementor-widget-heading\" data-id=\"34656d5\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h3>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-9df3b0a elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"9df3b0a\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-82d8822\" data-id=\"82d8822\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-e95c9c6 elementor-widget elementor-widget-text-editor\" data-id=\"e95c9c6\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>The Naive Bayes classifier is a decent classification algorithm that relaxes the naive bayes theorem based on the assumption conditional independence of features given the class variable to devise a computable classification score. The performance of the algorithm can be improved using kernel-based density estimation to build from data the conditional probabilities of the method and yield more accurate results.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-d261c84 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"d261c84\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-bd36fc3\" data-id=\"bd36fc3\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-8ae0359 elementor-widget elementor-widget-text-editor\" data-id=\"8ae0359\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p><strong>Author: Yves Matanga, PhD<\/strong><\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Naive Bayes Classifier The Naive Bayes classifier is a classification method that takes the assumption of independence in features to relax the Bayes theorem and build a classification method. \\[P(B|A) = frac{P(A cap B) }{P(A)} = frac{P(A|B)P(B)}{P(A)}\\] \\[P(Y=k|X=[x_1,x_2,..x_n]) = frac{P( x_1 cap x_2 ..cap\u00a0 x_n cap Y=k)}{P(x_1 cap x_2 &#8230;cap x_n)}\\] Deriving the Naive Bayes &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"https:\/\/mlinsightscentral.com\/index.php\/naive-bayes-classifier\/\"> <span class=\"screen-reader-text\">Naive Bayes Classifier<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"_uag_custom_page_level_css":"","site-sidebar-layout":"no-sidebar","site-content-layout":"page-builder","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"disabled","ast-breadcrumbs-content":"","ast-featured-img":"disabled","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","footnotes":""},"wf_page_folders":[36],"class_list":["post-2577","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.11 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Naive Bayes Classifier - MLInsightsCentral<\/title>\n<meta name=\"description\" content=\"The Naive Bayes classifier is a classification method that takes the assumption of independence between features to relaxe the Bayes Theorem and built a classifier.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/mlinsightscentral.com\/index.php\/naive-bayes-classifier\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Naive Bayes Classifier - MLInsightsCentral\" \/>\n<meta property=\"og:description\" content=\"The Naive Bayes classifier is a classification method that takes the assumption of independence between features to relaxe the Bayes Theorem and built a classifier.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/mlinsightscentral.com\/index.php\/naive-bayes-classifier\/\" \/>\n<meta property=\"og:site_name\" content=\"MLInsightsCentral\" \/>\n<meta property=\"article:modified_time\" content=\"2023-11-24T13:37:52+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/mlinsightscentral.com\/wp-content\/uploads\/2023\/11\/naive_bayes-768x419.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/mlinsightscentral.com\/index.php\/naive-bayes-classifier\/\",\"url\":\"https:\/\/mlinsightscentral.com\/index.php\/naive-bayes-classifier\/\",\"name\":\"Naive Bayes Classifier - MLInsightsCentral\",\"isPartOf\":{\"@id\":\"https:\/\/mlinsightscentral.com\/#website\"},\"datePublished\":\"2023-10-29T14:18:00+00:00\",\"dateModified\":\"2023-11-24T13:37:52+00:00\",\"description\":\"The Naive Bayes classifier is a classification method that takes the assumption of independence between features to relaxe the Bayes Theorem and built a classifier.\",\"breadcrumb\":{\"@id\":\"https:\/\/mlinsightscentral.com\/index.php\/naive-bayes-classifier\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/mlinsightscentral.com\/index.php\/naive-bayes-classifier\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/mlinsightscentral.com\/index.php\/naive-bayes-classifier\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/mlinsightscentral.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Naive Bayes Classifier\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/mlinsightscentral.com\/#website\",\"url\":\"https:\/\/mlinsightscentral.com\/\",\"name\":\"MLInsightsCentral\",\"description\":\"Learn Machine Learning and AI for engineers, data scientists and AI practionners.\",\"publisher\":{\"@id\":\"https:\/\/mlinsightscentral.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/mlinsightscentral.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/mlinsightscentral.com\/#organization\",\"name\":\"MLInsightsCentral\",\"url\":\"https:\/\/mlinsightscentral.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/mlinsightscentral.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/mlinsightscentral.com\/wp-content\/uploads\/2023\/06\/cropped-1290538dccf74accb0ae585ff4e8586c-1.png\",\"contentUrl\":\"https:\/\/mlinsightscentral.com\/wp-content\/uploads\/2023\/06\/cropped-1290538dccf74accb0ae585ff4e8586c-1.png\",\"width\":200,\"height\":110,\"caption\":\"MLInsightsCentral\"},\"image\":{\"@id\":\"https:\/\/mlinsightscentral.com\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Naive Bayes Classifier - MLInsightsCentral","description":"The Naive Bayes classifier is a classification method that takes the assumption of independence between features to relaxe the Bayes Theorem and built a classifier.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/mlinsightscentral.com\/index.php\/naive-bayes-classifier\/","og_locale":"en_US","og_type":"article","og_title":"Naive Bayes Classifier - MLInsightsCentral","og_description":"The Naive Bayes classifier is a classification method that takes the assumption of independence between features to relaxe the Bayes Theorem and built a classifier.","og_url":"https:\/\/mlinsightscentral.com\/index.php\/naive-bayes-classifier\/","og_site_name":"MLInsightsCentral","article_modified_time":"2023-11-24T13:37:52+00:00","og_image":[{"url":"https:\/\/mlinsightscentral.com\/wp-content\/uploads\/2023\/11\/naive_bayes-768x419.png"}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/mlinsightscentral.com\/index.php\/naive-bayes-classifier\/","url":"https:\/\/mlinsightscentral.com\/index.php\/naive-bayes-classifier\/","name":"Naive Bayes Classifier - MLInsightsCentral","isPartOf":{"@id":"https:\/\/mlinsightscentral.com\/#website"},"datePublished":"2023-10-29T14:18:00+00:00","dateModified":"2023-11-24T13:37:52+00:00","description":"The Naive Bayes classifier is a classification method that takes the assumption of independence between features to relaxe the Bayes Theorem and built a classifier.","breadcrumb":{"@id":"https:\/\/mlinsightscentral.com\/index.php\/naive-bayes-classifier\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/mlinsightscentral.com\/index.php\/naive-bayes-classifier\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/mlinsightscentral.com\/index.php\/naive-bayes-classifier\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/mlinsightscentral.com\/"},{"@type":"ListItem","position":2,"name":"Naive Bayes Classifier"}]},{"@type":"WebSite","@id":"https:\/\/mlinsightscentral.com\/#website","url":"https:\/\/mlinsightscentral.com\/","name":"MLInsightsCentral","description":"Learn Machine Learning and AI for engineers, data scientists and AI practionners.","publisher":{"@id":"https:\/\/mlinsightscentral.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/mlinsightscentral.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/mlinsightscentral.com\/#organization","name":"MLInsightsCentral","url":"https:\/\/mlinsightscentral.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/mlinsightscentral.com\/#\/schema\/logo\/image\/","url":"https:\/\/mlinsightscentral.com\/wp-content\/uploads\/2023\/06\/cropped-1290538dccf74accb0ae585ff4e8586c-1.png","contentUrl":"https:\/\/mlinsightscentral.com\/wp-content\/uploads\/2023\/06\/cropped-1290538dccf74accb0ae585ff4e8586c-1.png","width":200,"height":110,"caption":"MLInsightsCentral"},"image":{"@id":"https:\/\/mlinsightscentral.com\/#\/schema\/logo\/image\/"}}]}},"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"admin","author_link":"https:\/\/mlinsightscentral.com\/index.php\/author\/yvesm\/"},"uagb_comment_info":0,"uagb_excerpt":"Naive Bayes Classifier The Naive Bayes classifier is a classification method that takes the assumption of independence in features to relax the Bayes theorem and build a classification method. \\[P(B|A) = frac{P(A cap B) }{P(A)} = frac{P(A|B)P(B)}{P(A)}\\] \\[P(Y=k|X=[x_1,x_2,..x_n]) = frac{P( x_1 cap x_2 ..cap\u00a0 x_n cap Y=k)}{P(x_1 cap x_2 &#8230;cap x_n)}\\] Deriving the Naive Bayes&hellip;","_links":{"self":[{"href":"https:\/\/mlinsightscentral.com\/index.php\/wp-json\/wp\/v2\/pages\/2577","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mlinsightscentral.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/mlinsightscentral.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/mlinsightscentral.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mlinsightscentral.com\/index.php\/wp-json\/wp\/v2\/comments?post=2577"}],"version-history":[{"count":209,"href":"https:\/\/mlinsightscentral.com\/index.php\/wp-json\/wp\/v2\/pages\/2577\/revisions"}],"predecessor-version":[{"id":2940,"href":"https:\/\/mlinsightscentral.com\/index.php\/wp-json\/wp\/v2\/pages\/2577\/revisions\/2940"}],"wp:attachment":[{"href":"https:\/\/mlinsightscentral.com\/index.php\/wp-json\/wp\/v2\/media?parent=2577"}],"wp:term":[{"taxonomy":"wf_page_folders","embeddable":true,"href":"https:\/\/mlinsightscentral.com\/index.php\/wp-json\/wp\/v2\/wf_page_folders?post=2577"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}