Skip to content

riyazbhat/Naive_Bayes_Classifier

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Naive Bayes Classifier

Implementation of Multinomial Naive Bayes and Gaussian Naive Bayes:

Example:

>>> import NaiveBayes as nb
>>> 
>>> X = [[3.4, 0.2], [3.7, 0.4], [3.6, 0.2], [3.3, 0.5], [3.4, 0.2],
...      [3.2, 1.8], [2.8, 1.3], [2.5, 1.5], [2.8, 1.2], [2.9, 1.3],
...      [3.2, 1.8], [2.8, 1.8], [3.0, 1.8], [2.8, 2.1], [3.0, 1.6]]
>>> 
>>> y = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2]
>>> 
>>> test = [[3.2, 0.2], [3.5, 0.2], [3.1, 0.1], [3.0, 0.2], [3.4, 0.2],
...         [2.4, 1.1], [2.4, 1.0], [2.7, 1.2], [2.7, 1.6], [3.0, 1.5],
...         [3.0, 2.3], [3.4, 2.4], [3.1, 1.8], [3.0, 1.8], [3.1, 2.1]]
>>> 
>>> clf = nb.multinomialNB()
>>> clf.fit(X, y)
>>> 
>>> clf.predict(X)
[0, 0, 0, 0, 0, 2, 1, 1, 1, 1, 2, 2, 2, 2, 2]
>>> 
>>> clf = nb.gaussianNB()
>>> clf.fit(X, y)
>>> 
>>> clf.predict(test)
[0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2]

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%