Likelihood function with Laplace smoothing:
Posteriors function:
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