Skip to main content
Donate to the Python Software Foundation or Purchase a PyCharm License to Benefit the PSF! Donate Now


Project description

Documentation Pypi


Python implementations of Naive Bayes algorithm variations with sklearn-like API.


  • Complement Naive Bayes
  • Negation Naive Bayes
  • Universal-set Naive Bayes
  • Selective Naive Bayes


You can install this module directly from GitHub repo with command:

pip install git+

or using pip:

pip install bayes-variants


Bayes classifiers API mimics [Scikit-Learn]( API, so usage is very simple.

from bayes.classifiers import ComplementNB
from sklearn.datasets import fetch_20newsgroups
from sklearn.feature_extraction.text import CountVectorizer

vectorizer = CountVectorizer()
categories = ['alt.atheism', 'talk.religion.misc',
              '', '']

# Train set
newsgroups_train = fetch_20newsgroups(subset='train',
                                          categories=categories, shuffle=True)
X_train = vectorizer.fit_transform(
y_train =

# Test set
newsgroups_test = fetch_20newsgroups(subset='test',
                                          categories=categories, shuffle=True)
X_test = vectorizer.fit_transform(
y_test =

# Score
cnb = ComplementNB(), y_train).accuracy_score(X_test, y_test)

TODO list

  • Weighted Complement Naive Bayes
  • Locally Weighted Naive Bayes


The full documentation is at

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
bayes-variants-0.1.1.tar.gz (9.6 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page