{"id":930,"date":"2018-12-15T16:30:32","date_gmt":"2018-12-15T22:30:32","guid":{"rendered":"http:\/\/www.jacobsoft.com.mx\/?p=930"},"modified":"2025-02-20T13:37:49","modified_gmt":"2025-02-20T19:37:49","slug":"clasificador-naive-bayes","status":"publish","type":"post","link":"https:\/\/www.jacobsoft.com.mx\/en\/clasificador-naive-bayes\/","title":{"rendered":"Naive Bayes Classifier"},"content":{"rendered":"<h2 class=\"wp-block-heading\">Naive Bayes classifier with Python<\/h2>\n\n\n\n<p>Both in <strong><a aria-label=\"Tanto en probabilidad como en miner\u00eda de datos, un clasificador ingenuo de Naive Bayes es un m\u00e9todo probabil\u00edstico que tiene sus bases en el teorema de Bayes y recibe el apelativo de ingenuo dadas algunas simplificaciones adicionales que determinan la hip\u00f3tesis de independencia de las variables predictoras. (opens in a new tab)\" rel=\"noreferrer noopener\" href=\"https:\/\/click.linksynergy.com\/fs-bin\/click?id=cTjR400Zjac&amp;offerid=621876.8&amp;subid=0&amp;type=4\" target=\"_blank\">probability <\/a><\/strong>like in <strong><a aria-label=\"Tanto en probabilidad como en miner\u00eda de datos, un clasificador ingenuo de Naive Bayes es un m\u00e9todo probabil\u00edstico que tiene sus bases en el teorema de Bayes y recibe el apelativo de ingenuo dadas algunas simplificaciones adicionales que determinan la hip\u00f3tesis de independencia de las variables predictoras. (opens in a new tab)\" rel=\"noreferrer noopener\" href=\"http:\/\/=https:\/\/click.linksynergy.com\/fs-bin\/click?id=cTjR400Zjac&amp;offerid=621876.12&amp;subid=0&amp;type=4\" target=\"_blank\">data mining<\/a><\/strong>, a <strong>naive classifier<\/strong> Bayesiano (clasificador naive bayes) es un m\u00e9todo probabil\u00edstico que tiene sus bases en el <strong><a aria-label=\"Tanto en probabilidad como en miner\u00eda de datos, un clasificador ingenuo Bayesiano es un m\u00e9todo probabil\u00edstico que tiene sus bases en el teorema de Bayes y recibe el apelativo de ingenuo dadas algunas simplificaciones adicionales que determinan la hip\u00f3tesis de independencia de las variables predictoras. (opens in a new tab)\" rel=\"noreferrer noopener\" href=\"https:\/\/click.linksynergy.com\/fs-bin\/click?id=cTjR400Zjac&amp;offerid=621876.12&amp;type=3&amp;subid=0\" target=\"_blank\">Bayes theorem<\/a><\/strong> and receives the name of <strong>naive <\/strong>given some additional simplifications that determine the hypothesis of independence of the predictor variables.<\/p>\n\n\n\n<p>Si quieres verlo en video:<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube is-provider-gestor-del-servicio wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Naive Bayes classifier with Python\" width=\"780\" height=\"439\" src=\"https:\/\/www.youtube.com\/embed\/hXwUI9Q3GAU?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>The argument of&nbsp;<strong>Bayes&nbsp;<\/strong>it is not that the world is intrinsically probabilistic or uncertain, but that we learn about the world through approximation, getting closer and closer to the truth, as we gather more evidence.<\/p>\n\n\n\n<p>In simple terms, the naive classifier of <strong>Bayes<\/strong> assumes that <strong><em>presence <\/em><\/strong>or <strong><em>absence <\/em><\/strong>of a particular characteristic is not related to the presence or absence of any other characteristic. <strong><em>For example<\/em><\/strong>, a fruit can be considered as an apple if it is red, round and about 7 cm in diameter. <\/p>\n\n\n\n<p>A classifier <strong><a rel=\"noreferrer noopener\" aria-label=\"Un clasificador ingenuo de Bayes considera que cada una de estas caracter\u00edsticas contribuye de manera independiente a la probabilidad de que esta fruta sea una manzana, independientemente de la presencia o ausencia de las otras caracter\u00edsticas. (opens in a new tab)\" href=\"https:\/\/click.linksynergy.com\/fs-bin\/click?id=cTjR400Zjac&amp;offerid=621876.30&amp;type=3&amp;subid=0\" target=\"_blank\">naive Bayes<\/a><\/strong> considers that each of these characteristics contributes independently to the <strong>probability <\/strong>that this fruit is an apple, regardless of the presence or absence of the other characteristics.<\/p>\n\n\n\n<p>In many practical applications, the estimation of parameters for the Bayes models use the method of <strong><em>maximum likelihood<\/em><\/strong>, that is, one can work with Bayes&#039; naive model without accepting the Bayesian probability or any of the Bayesian methods.<\/p>\n\n\n\n<p>An advantage of <strong><a href=\"https:\/\/click.linksynergy.com\/link?id=cTjR400Zjac&amp;offerid=145238.2267074&amp;type=2&amp;murl=http%3A%2F%2Fwww.informit.com%2Ftitle%2F9780134116570\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"Una ventaja del clasificador ingenuo de Bayes es que solo se requiere una peque\u00f1a cantidad de datos de entrenamiento para estimar los par\u00e1metros necesarios para la clasificaci\u00f3n (las medidas y las varianzas de las variables).  (opens in a new tab)\">naive Bayes classifier<\/a><\/strong> is that only a small amount of training data is required to estimate the parameters needed for the classification (the measures and variances of the variables). <\/p>\n\n\n\n<p>It is only necessary to determine the variances of the variables of each class and not the entire covariance matrix. For others <strong><a aria-label=\"Solo es necesario determinar las varianzas de las variables de cada clase y no toda la matriz de covarianza.&nbsp;Para otros modelos de probabilidad, los clasificadores ingenuos de Bayes&nbsp; se pueden entrenar en entornos de aprendizaje supervisado.&nbsp; (opens in a new tab)\" href=\"https:\/\/click.linksynergy.com\/link?id=cTjR400Zjac&amp;offerid=145238.2816112&amp;type=2&amp;murl=http%3A%2F%2Fwww.informit.com%2Ftitle%2F9780134863931\" target=\"_blank\" rel=\"noreferrer noopener\">probability models<\/a><\/strong>, Bayes naive classifiers can be trained in supervised learning environments.&nbsp;<\/p>\n\n\n\n<p><\/p>\n\n\n\n<script async src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-2380084220870127\"\n     crossorigin=\"anonymous\"><\/script>\n<ins class=\"adsbygoogle\"\n     style=\"display:block; text-align:center;\"\n     data-ad-layout=\"in-article\"\n     data-ad-format=\"fluid\"\n     data-ad-client=\"ca-pub-2380084220870127\"\n     data-ad-slot=\"2437322509\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Bayes theorem<\/h2>\n\n\n\n<p>The <strong><a href=\"https:\/\/click.linksynergy.com\/fs-bin\/click?id=cTjR400Zjac&amp;offerid=621876.30&amp;type=3&amp;subid=0\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"El teorema de bayes esta expresado por la siguiente ecuaci\u00f3n: (opens in a new tab)\">bayes theorem<\/a><\/strong> is expressed by the following equation:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"352\" height=\"92\" src=\"https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes1.png\" alt=\"clasificador naive bayes\" class=\"wp-image-935\" srcset=\"https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes1.png 352w, https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes1-300x78.png 300w\" sizes=\"auto, (max-width: 352px) 100vw, 352px\" \/><figcaption>Bayes theorem<\/figcaption><\/figure><\/div>\n\n\n\n<p><strong>P (H)<\/strong> is the probability <strong><em>a priori<\/em><\/strong>, the way to introduce prior knowledge about the values that the hypothesis can take.<\/p>\n\n\n\n<p><strong>P (D | H)<\/strong> is the <strong><em>likelihood<\/em><\/strong>&nbsp;of a hypothesis H given the data D, that is, the probability of obtaining D since H is true.<\/p>\n\n\n\n<p><strong>P.S)<\/strong> is the<strong><em> marginal likelihood<\/em><\/strong> or<strong><em> evidence<\/em><\/strong>, is the probability of observing the D data averaged over all possible H hypotheses.<\/p>\n\n\n\n<p><strong>P (H | D)<\/strong> is the<strong><em> a posteriori<\/em><\/strong>, the final probability distribution for the hypothesis. It is the logical consequence of having used a set of data, a <strong><em>likelihood <\/em><\/strong>and a <strong><em>a priori<\/em><\/strong>.<\/p>\n\n\n\n<p>About a dependent variable <strong>H<\/strong>, with a small number of classes, the variable is conditioned by several independent variables&nbsp;<strong>D<\/strong>&nbsp;= {d1, d2, ..., dn} which, given the assumption of conditional independence of bayes, assumes that each <strong>gave<\/strong> it is independent of any other <strong>DJ<\/strong> for <strong>i<\/strong> different from <strong>j<\/strong> and we can express it in simple terms in the following way:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"389\" height=\"70\" src=\"https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes1b.png\" alt=\"\" class=\"wp-image-939\" srcset=\"https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes1b.png 389w, https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes1b-300x54.png 300w\" sizes=\"auto, (max-width: 389px) 100vw, 389px\" \/><figcaption>Bayes&#039; theorem in simple terms<\/figcaption><\/figure><\/div>\n\n\n\n<p>The formula tells us the probability that a hypothesis <strong>H<\/strong> be true if any event <strong>D<\/strong> has happened. This is important since, normally, we get the <strong><em>probability of the effects given the causes,<\/em><\/strong> but <strong><em><a href=\"https:\/\/click.linksynergy.com\/fs-bin\/click?id=cTjR400Zjac&amp;offerid=621876.12&amp;type=3&amp;subid=0\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"La formula nos indica la probabilidad de que una hip\u00f3tesis H sea verdadera si alg\u00fan evento D ha sucedido. Esto es importante dado que, normalmente obtenemos la probabilidad de los efectos dadas las causas, pero el teorema de bayes nos indica la probabilidad de las causas dados los efectos. (opens in a new tab)\">bayes theorem<\/a><\/em><\/strong> tells us the probability of <strong><em>Causes <\/em><\/strong>given the <strong><em>effects<\/em><\/strong>.<\/p>\n\n\n\n<p><strong>For example<\/strong>, we can know what is the percentage of patients with <strong><em>flu <\/em><\/strong>that have <strong><em>fever<\/em><\/strong>, but what we really want to know is the probability that a patient with <strong><em>fever <\/em><\/strong>have <strong><em>flu<\/em><\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Example<\/h2>\n\n\n\n<p>We have two machines (m1 and m2) that manufacture the same tool<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"858\" height=\"376\" src=\"https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes3.png\" alt=\"\" class=\"wp-image-947\" srcset=\"https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes3.png 858w, https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes3-300x131.png 300w, https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes3-768x337.png 768w\" sizes=\"auto, (max-width: 858px) 100vw, 858px\" \/><figcaption>Two machines that manufacture the same tool<\/figcaption><\/figure><\/div>\n\n\n\n<p>Of all the tools manufactured by each of the machines, some are produced with defects.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"622\" height=\"444\" src=\"https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes4.png\" alt=\"\" class=\"wp-image-948\" srcset=\"https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes4.png 622w, https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes4-300x214.png 300w\" sizes=\"auto, (max-width: 622px) 100vw, 622px\" \/><figcaption>Tools produced by machines m1 and m2, some with defects (black color)<\/figcaption><\/figure><\/div>\n\n\n\n<p>If we consider that machine 1 produces 30 keys per hour and machine 2 produces 20 keys per hour, of all the parts produced it is observed that 1% are defective and of all the defective keys 50% come from machine 1 and the 50% of the machine 2.<\/p>\n\n\n\n<p><strong>What is the probability that a defective part was produced by machine 2?<\/strong><\/p>\n\n\n\n<p>If M1: 30 keys \/ hour, M2: 20 keys \/ hour<br>of the defective 50% are of M1 and 50% of M2<\/p>\n\n\n\n<p>P (M1) = 30\/50 = 0.6<br>P (M2) = 20\/50 = 0.4<br>P (Default) = 1%<br>P (M1 | Default) = 50%<br>P (M2 | Default) = 50%<\/p>\n\n\n\n<p>What we want to know is then:<br>P (Defect | M2) =?<\/p>\n\n\n\n<p>Applying the Bayes Theorem<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"485\" height=\"78\" src=\"https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes5.png\" alt=\"\" class=\"wp-image-949\" srcset=\"https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes5.png 485w, https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes5-300x48.png 300w\" sizes=\"auto, (max-width: 485px) 100vw, 485px\" \/><figcaption>Bayes theorem for machines that produce keys<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"396\" height=\"74\" src=\"https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes7.png\" alt=\"\" class=\"wp-image-951\" srcset=\"https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes7.png 396w, https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes7-300x56.png 300w\" sizes=\"auto, (max-width: 396px) 100vw, 396px\" \/><figcaption>Substituting the value of the probabilities<\/figcaption><\/figure><\/div>\n\n\n\n<p>The probability that a defective part is of machine 2 is 1.25%<\/p>\n\n\n\n<p>In a production of 1,000 pieces, then 400 come from machine 2 and if 1% is defective there will be 10 defective parts. of those 10 pieces, 50% are machine 2, that is, 5 pieces, we can verify that the percentage of defective parts of machine 2 is 5\/400 = 0.0125<\/p>\n\n\n\n<p><\/p>\n\n\n\n<script async src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-2380084220870127\"\n     crossorigin=\"anonymous\"><\/script>\n<ins class=\"adsbygoogle\"\n     style=\"display:block; text-align:center;\"\n     data-ad-layout=\"in-article\"\n     data-ad-format=\"fluid\"\n     data-ad-client=\"ca-pub-2380084220870127\"\n     data-ad-slot=\"2437322509\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n\n\n\n<h2 class=\"wp-block-heading\"><br>Algoritmo del Clasificador Naive Bayes<\/h2>\n\n\n\n<p>We have a set of data of people who walk or drive towards their work, in relation to their age and their salary, for example.&nbsp;<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes8.png\" alt=\"\" class=\"wp-image-952\" width=\"528\" height=\"303\" srcset=\"https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes8.png 763w, https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes8-300x173.png 300w\" sizes=\"auto, (max-width: 528px) 100vw, 528px\" \/><figcaption>People who walk or drive to work in relation to age and salary<\/figcaption><\/figure><\/div>\n\n\n\n<p>If we now have the age and the salary of a new person, we want to classify it, according to that data, if it is of the people who walk or of those who drive.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes9.png\" alt=\"\" class=\"wp-image-953\" width=\"533\" height=\"308\" srcset=\"https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes9.png 760w, https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes9-300x174.png 300w\" sizes=\"auto, (max-width: 533px) 100vw, 533px\" \/><figcaption>A new person whose age and salary we have, are those who drive or walk?<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"465\" height=\"249\" src=\"https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes-2.png\" alt=\"\" class=\"wp-image-955\" srcset=\"https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes-2.png 465w, https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes-2-300x161.png 300w\" sizes=\"auto, (max-width: 465px) 100vw, 465px\" \/><figcaption>Bayes theorem to classify a new person based on his age and salary<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes-3.png\" alt=\"\" class=\"wp-image-956\" width=\"552\" height=\"210\" srcset=\"https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes-3.png 858w, https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes-3-300x115.png 300w, https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes-3-768x294.png 768w\" sizes=\"auto, (max-width: 552px) 100vw, 552px\" \/><figcaption>P (Walk) is the number of people who walk among the total observations<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes-4.png\" alt=\"\" class=\"wp-image-957\" width=\"542\" height=\"189\" srcset=\"https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes-4.png 858w, https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes-4-300x105.png 300w, https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes-4-768x269.png 768w\" sizes=\"auto, (max-width: 542px) 100vw, 542px\" \/><figcaption>P (X) is the number of observations similar to the new point, among the total observations<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes-6.png\" alt=\"\" class=\"wp-image-958\" width=\"548\" height=\"191\" srcset=\"https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes-6.png 858w, https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes-6-300x105.png 300w, https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes-6-768x269.png 768w\" sizes=\"auto, (max-width: 548px) 100vw, 548px\" \/><figcaption>P (X | Walk) is the number of similar observations among those who walk among the total of those who walk<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes-7.png\" alt=\"\" class=\"wp-image-959\" width=\"518\" height=\"221\" srcset=\"https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes-7.png 858w, https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes-7-300x129.png 300w, https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes-7-768x329.png 768w\" sizes=\"auto, (max-width: 518px) 100vw, 518px\" \/><figcaption>Applying the values to the formula of the theorem<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes-8.png\" alt=\"\" class=\"wp-image-960\" width=\"519\" height=\"223\" srcset=\"https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes-8.png 858w, https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes-8-300x129.png 300w, https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes-8-768x330.png 768w\" sizes=\"auto, (max-width: 519px) 100vw, 519px\" \/><figcaption>Also for those who drive<\/figcaption><\/figure><\/div>\n\n\n\n<p>If we now compare those who walk against those who drive we must:<\/p>\n\n\n\n<p class=\"has-text-align-center\"><strong>P (Walk | X)&gt; P (Drive | X)<\/strong><br><strong>0.75&gt; 0.25<\/strong><\/p>\n\n\n\n<p>Then, this new point that represents the age and salary of a new person, will be classified in the group of those who walk.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes-9.png\" alt=\"\" class=\"wp-image-961\" width=\"542\" height=\"313\" srcset=\"https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes-9.png 760w, https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes-9-300x173.png 300w\" sizes=\"auto, (max-width: 542px) 100vw, 542px\" \/><figcaption>The new point has been classified among people who walk<\/figcaption><\/figure><\/div>\n\n\n\n<p><\/p>\n\n\n\n<script async src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-2380084220870127\"\n     crossorigin=\"anonymous\"><\/script>\n<ins class=\"adsbygoogle\"\n     style=\"display:block; text-align:center;\"\n     data-ad-layout=\"in-article\"\n     data-ad-format=\"fluid\"\n     data-ad-client=\"ca-pub-2380084220870127\"\n     data-ad-slot=\"2437322509\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Naive Bayes with Python<\/h2>\n\n\n\n<p>For the exercise with <strong><a rel=\"noreferrer noopener\" aria-label=\"Para el ejercicio con python utilizaremos un conjunto de datos con informaci\u00f3n de clientes que compraron o no compraron en una tienda en relaci\u00f3n a su edad y su salario principalmente (opens in a new tab)\" href=\"https:\/\/click.linksynergy.com\/fs-bin\/click?id=cTjR400Zjac&amp;offerid=347188.10000502&amp;type=3&amp;subid=0\" target=\"_blank\">python <\/a><\/strong>We will use a set of data with information of customers who bought or did not buy in a store in relation to their age and their salary mainly.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"679\" height=\"558\" src=\"https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes10.png\" alt=\"\" class=\"wp-image-963\" srcset=\"https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes10.png 679w, https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/bayes10-300x247.png 300w\" sizes=\"auto, (max-width: 679px) 100vw, 679px\" \/><figcaption>Data set for exercise with python<\/figcaption><\/figure><\/div>\n\n\n\n<iframe loading=\"lazy\" src=\"https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/naive_bayes.html\" width=\"99%\" height=\"2200\" frameborder=\"0\" scrolling=\"auto\"><\/iframe>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusions<\/h2>\n\n\n\n<p>To delve more about the subject and start with python, this video guide is very good and allows you to go from the basics to the intermediate: <strong><a rel=\"noreferrer noopener\" aria-label=\"Para ahondar m\u00e1s sobre el tema e iniciarte con python, esta gu\u00eda en video es muy buena y te permite ir de lo b\u00e1sico a lo intermedio: Gu\u00eda en Video (opens in a new tab)\" href=\"https:\/\/click.linksynergy.com\/link?id=cTjR400Zjac&amp;offerid=145238.2143362&amp;type=2&amp;murl=http%3A%2F%2Fwww.informit.com%2Ftitle%2F9780133805338\" target=\"_blank\">Video Guide<\/a><\/strong><\/p>\n\n\n\n<p>This other more advanced one includes analysis with pandas and other libraries of frequent use: <strong><a href=\"https:\/\/click.linksynergy.com\/link?id=cTjR400Zjac&amp;offerid=145238.2255416&amp;type=2&amp;murl=http%3A%2F%2Fwww.informit.com%2Ftitle%2F9780134097350\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"Este otro m\u00e1s avanzado incluye an\u00e1lisis con pandas y otras librer\u00edas de uso frecuente: Lecciones en vivo (opens in a new tab)\">Live lessons<\/a><\/strong><\/p>\n\n\n\n<p>Additionally, the basics of data analysis with python can be found in this <strong><a href=\"https:\/\/click.linksynergy.com\/link?id=cTjR400Zjac&amp;offerid=145238.2115609&amp;type=2&amp;murl=http%3A%2F%2Fwww.informit.com%2Ftitle%2F9780133599459\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"Adicionalmente, los fundamentos del an\u00e1lisis de datos con python los puedes encontrar en este video de entrenamiento. (opens in a new tab)\">training video<\/a><\/strong>.<\/p>\n\n\n\n<p>You can also take training in data science and pay when you have got the job as a data scientist, this is an excellent offer: <strong><a href=\"https:\/\/click.linksynergy.com\/fs-bin\/click?id=cTjR400Zjac&amp;offerid=621876.12&amp;type=3&amp;subid=0\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"Puedes tambi\u00e9n tomar el entrenamiento en ciencia de datos y pagar cuando hayas conseguido el trabajo como cient\u00edfico de datos, esta es una oferta excelente: Formaci\u00f3n en ciencia de datos (opens in a new tab)\">Training in data science<\/a><\/strong><\/p>\n\n\n\n<p>Finally, the certification <strong><a rel=\"noreferrer noopener\" aria-label=\"Finalmente, la certificaci\u00f3n AWS Asociado o AWS Profesional est\u00e1n muy accesibles y son herramientas indispensables (opens in a new tab)\" href=\"https:\/\/click.linksynergy.com\/fs-bin\/click?id=cTjR400Zjac&amp;offerid=579862.373&amp;type=3&amp;subid=0&amp;LSNSUBSITE=LSNSUBSITE\" target=\"_blank\">AWS Associate<\/a><\/strong> or <strong><a rel=\"noreferrer noopener\" aria-label=\"Finalmente, la certificaci\u00f3n AWS Asociado o AWS Profesional est\u00e1n muy accesibles y son herramientas indispensables (opens in a new tab)\" href=\"https:\/\/click.linksynergy.com\/fs-bin\/click?id=cTjR400Zjac&amp;offerid=579862.372&amp;type=3&amp;subid=0&amp;LSNSUBSITE=LSNSUBSITE\" target=\"_blank\">AWS Professional<\/a><\/strong> They are very accessible and indispensable tools in the subject.<\/p>\n\n\n\n<p>A very interesting webinar about Azure is the following: <strong><a href=\"https:\/\/click.linksynergy.com\/fs-bin\/click?id=cTjR400Zjac&amp;offerid=579862.462&amp;type=3&amp;subid=0&amp;LSNSUBSITE=LSNSUBSITE\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"Un webinar bastante interesante sobre Azure es el siguiente: Webinar Azure (opens in a new tab)\">Webinar Azure<\/a><\/strong><\/p>\n\n\n\n<p><strong><a href=\"https:\/\/click.linksynergy.com\/link?id=cTjR400Zjac&amp;offerid=145238.2790534&amp;type=2&amp;murl=http%3A%2F%2Fwww.informit.com%2Ftitle%2F9780134846019\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"Data analytics with Spark using Python (opens in a new tab)\">Data analytics with Spark using Python<\/a><\/strong><\/p>\n\n\n\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>Clasificador Naive Bayes con Python Tanto en probabilidad como en miner\u00eda de datos, un clasificador &hellip; <\/p>","protected":false},"author":2,"featured_media":931,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"advgb_blocks_editor_width":"","advgb_blocks_columns_visual_guide":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[25,35,46],"tags":[99,55,98,58,56,82,50,59,97,100,61],"class_list":["post-930","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-algoritmos","category-inteligencia-artificial","category-machine-learning","tag-artificial-intelligence","tag-clasificacion","tag-clasificador","tag-data-mining","tag-data-science","tag-inteligencia-artificial","tag-machine-learning","tag-mineria-de-datos","tag-naive-bayes","tag-naive-bayes-with-python","tag-python"],"aioseo_notices":[],"author_meta":{"display_name":"Jacob Avila Camacho","author_link":"https:\/\/www.jacobsoft.com.mx\/en\/author\/jacob-avila\/"},"featured_img":"https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/destacada_naive_bayes-300x169.png","featured_image_src":"https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/destacada_naive_bayes.png","featured_image_src_square":"https:\/\/www.jacobsoft.com.mx\/wp-content\/uploads\/2018\/12\/destacada_naive_bayes.png","author_info":{"display_name":"Jacob Avila Camacho","author_link":"https:\/\/www.jacobsoft.com.mx\/en\/author\/jacob-avila\/"},"coauthors":[],"tax_additional":{"categories":{"linked":["<a href=\"https:\/\/www.jacobsoft.com.mx\/en\/category\/algoritmos\/\" class=\"advgb-post-tax-term\">Algoritmos<\/a>","<a href=\"https:\/\/www.jacobsoft.com.mx\/en\/category\/inteligencia-artificial\/\" class=\"advgb-post-tax-term\">Inteligencia Artificial<\/a>","<a href=\"https:\/\/www.jacobsoft.com.mx\/en\/category\/inteligencia-artificial\/machine-learning\/\" class=\"advgb-post-tax-term\">Machine Learning<\/a>"],"unlinked":["<span class=\"advgb-post-tax-term\">Algoritmos<\/span>","<span class=\"advgb-post-tax-term\">Inteligencia Artificial<\/span>","<span class=\"advgb-post-tax-term\">Machine Learning<\/span>"]},"tags":{"linked":["<a href=\"https:\/\/www.jacobsoft.com.mx\/en\/category\/inteligencia-artificial\/machine-learning\/\" class=\"advgb-post-tax-term\">Artificial Intelligence<\/a>","<a href=\"https:\/\/www.jacobsoft.com.mx\/en\/category\/inteligencia-artificial\/machine-learning\/\" class=\"advgb-post-tax-term\">clasificaci\u00f3n<\/a>","<a href=\"https:\/\/www.jacobsoft.com.mx\/en\/category\/inteligencia-artificial\/machine-learning\/\" class=\"advgb-post-tax-term\">Clasificador<\/a>","<a href=\"https:\/\/www.jacobsoft.com.mx\/en\/category\/inteligencia-artificial\/machine-learning\/\" class=\"advgb-post-tax-term\">Data Mining<\/a>","<a href=\"https:\/\/www.jacobsoft.com.mx\/en\/category\/inteligencia-artificial\/machine-learning\/\" class=\"advgb-post-tax-term\">Data Science<\/a>","<a href=\"https:\/\/www.jacobsoft.com.mx\/en\/category\/inteligencia-artificial\/machine-learning\/\" class=\"advgb-post-tax-term\">Inteligencia Artificial<\/a>","<a href=\"https:\/\/www.jacobsoft.com.mx\/en\/category\/inteligencia-artificial\/machine-learning\/\" class=\"advgb-post-tax-term\">machine learning<\/a>","<a href=\"https:\/\/www.jacobsoft.com.mx\/en\/category\/inteligencia-artificial\/machine-learning\/\" class=\"advgb-post-tax-term\">Miner\u00eda de Datos<\/a>","<a href=\"https:\/\/www.jacobsoft.com.mx\/en\/category\/inteligencia-artificial\/machine-learning\/\" class=\"advgb-post-tax-term\">Naive Bayes<\/a>","<a href=\"https:\/\/www.jacobsoft.com.mx\/en\/category\/inteligencia-artificial\/machine-learning\/\" class=\"advgb-post-tax-term\">Naive Bayes with Python<\/a>","<a href=\"https:\/\/www.jacobsoft.com.mx\/en\/category\/inteligencia-artificial\/machine-learning\/\" class=\"advgb-post-tax-term\">Python<\/a>"],"unlinked":["<span class=\"advgb-post-tax-term\">Artificial Intelligence<\/span>","<span class=\"advgb-post-tax-term\">clasificaci\u00f3n<\/span>","<span class=\"advgb-post-tax-term\">Clasificador<\/span>","<span class=\"advgb-post-tax-term\">Data Mining<\/span>","<span class=\"advgb-post-tax-term\">Data Science<\/span>","<span class=\"advgb-post-tax-term\">Inteligencia Artificial<\/span>","<span class=\"advgb-post-tax-term\">machine learning<\/span>","<span class=\"advgb-post-tax-term\">Miner\u00eda de Datos<\/span>","<span class=\"advgb-post-tax-term\">Naive Bayes<\/span>","<span class=\"advgb-post-tax-term\">Naive Bayes with Python<\/span>","<span class=\"advgb-post-tax-term\">Python<\/span>"]}},"comment_count":"19","relative_dates":{"created":"Posted 7 years ago","modified":"Updated 1 year ago"},"absolute_dates":{"created":"Posted on December 15, 2018","modified":"Updated on February 20, 2025"},"absolute_dates_time":{"created":"Posted on December 15, 2018 4:30 pm","modified":"Updated on February 20, 2025 1:37 pm"},"featured_img_caption":"","series_order":"","_links":{"self":[{"href":"https:\/\/www.jacobsoft.com.mx\/en\/wp-json\/wp\/v2\/posts\/930","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jacobsoft.com.mx\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jacobsoft.com.mx\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jacobsoft.com.mx\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jacobsoft.com.mx\/en\/wp-json\/wp\/v2\/comments?post=930"}],"version-history":[{"count":23,"href":"https:\/\/www.jacobsoft.com.mx\/en\/wp-json\/wp\/v2\/posts\/930\/revisions"}],"predecessor-version":[{"id":1804,"href":"https:\/\/www.jacobsoft.com.mx\/en\/wp-json\/wp\/v2\/posts\/930\/revisions\/1804"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.jacobsoft.com.mx\/en\/wp-json\/wp\/v2\/media\/931"}],"wp:attachment":[{"href":"https:\/\/www.jacobsoft.com.mx\/en\/wp-json\/wp\/v2\/media?parent=930"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jacobsoft.com.mx\/en\/wp-json\/wp\/v2\/categories?post=930"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jacobsoft.com.mx\/en\/wp-json\/wp\/v2\/tags?post=930"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}