Skip to content

Files

Latest commit

6caa056 · Jan 28, 2018

History

History

naive_bayes

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Jan 3, 2018
Jan 3, 2018
Jan 28, 2018

Document classification with Naive Bayes

Likelihood function with Laplace smoothing:

Posteriors function:

How to run:

In terminal, you should be able to run:

from src.naive_bayes import NaiveBayes
my_nb = NaiveBayes()
my_nb.fit(X_train, y_train)
print 'Accuracy:', my_nb.score(X_test, y_test)
my_predictions =  my_nb.predict(X_test)

To run compare the result of my implementation and sklearn's implementation, in terminal:

python src/run_naive_bayes.py

The dataset used in the comparison can be found here

Package Dependencies:

  • numpy==1.13.1
  • sklearn==0.18.1