title: Naive Bayes All columns HAVE TO be Factor? or not
body: <p>I am trying to understand how is Naive Bayes working. </p>
  
  <p>I have a dataset looks like this:</p>
  
  <pre><code>&gt; data.flu
      chills runnyNose headache fever flu
  1      1         0        M     1   0
  2      1         1        N     0   1
  3      1         0        S     1   1
  4      0         1        M     1   1
  5      0         0        N     0   0
  6      0         1        S     1   1
  7      0         1        S     0   0
  8      1         1        M     1   1
  </code></pre>
  
  <p>If the types of those columns look like this:</p>
  
  <pre><code>str(data.flu)
  'data.frame':  8 obs. of  5 variables:
    $ chills   : num  1 1 1 0 0 0 0 1
  $ runnyNose: num  0 1 0 1 0 1 1 1
  $ headache : Factor w/ 3 levels "M","N","S": 1 2 3 1 2 3 3 1
  $ fever    : num  1 0 1 1 0 1 0 1
  $ flu      : Factor w/ 2 levels "0","1": 1 2 2 2 1 2 1 2
  </code></pre>
  
  <p>The model will looks like this:</p>
  
  <pre><code>Naive Bayes Classifier for Discrete Predictors
  Call:
    naiveBayes.default(x = X, y = Y, laplace = laplace)
  A-priori probabilities:
    Y
  0     1 
  0.375 0.625 
  
  Conditional probabilities:
    chills
  Y        [,1]      [,2]
  0 0.3333333 0.5773503
  1 0.6000000 0.5477226
  ...
  </code></pre>
  
  <p>I am just so interesting to find that <code>P(chills=1|flu=1) + P(chills=0|flu=1) != 1</code>, in my point of view, when the <code>flu</code> is positive, a person either has chills or not.. Something absolutely went wrong against my elementary knowledge of probability. </p>
  
  <p>I verified my thought by changing all the types to factors and every number matches my handy calculation. </p>
  
  <pre><code>A-priori probabilities:
    Y
  0     1 
  0.375 0.625 
  
  Conditional probabilities:
    chills
  Y           0         1
  0 0.6666667 0.3333333
  1 0.4000000 0.6000000
  ...
  </code></pre>
  
  <p>Can anyone explain to me how is the probabilities in the first scenario calculated when the columns contains numeric columns... It will also be super helpful pointing me to any book or paper.  </p>
  
  <p>Many thanks</p>