Skip to main content

scikit-bayes

tests codecov doc Python License

scikit-bayes is a Python package that extends scikit-learn with a suite of Bayesian Network Classifiers.

The primary goal of this package is to provide robust, scikit-learn-compatible implementations of advanced Bayesian classifiers that are not available in the core library.

Key Features

  • MixedNB: Naive Bayes for mixed data types (Gaussian + Categorical + Bernoulli) in a single model
  • AnDE: Averaged n-Dependence Estimators (AODE, A2DE) that relax the independence assumption
  • ALR: Accelerated Logistic Regression - hybrid generative-discriminative models with 4 weight granularity levels
  • WeightedAnDE: Discriminatively-weighted ensemble models
  • Full scikit-learn API: Compatible with pipelines, cross-validation, and grid search

Quick Start

import numpy as np
from skbn import MixedNB, AnDE

# MixedNB: Handle mixed data types automatically
X = np.array([[1.5, 0, 2], [-0.5, 1, 0], [2.1, 1, 1], [-1.2, 0, 2]])
y = np.array([0, 1, 1, 0])

clf = MixedNB()
clf.fit(X, y)
print(clf.predict([[0.5, 1, 1]]))  # Automatically handles Gaussian, Bernoulli, Categorical

# AnDE: Solve problems Naive Bayes cannot (XOR)
X_xor = np.array([[-1, -1], [-1, 1], [1, -1], [1, 1]])
y_xor = np.array([0, 1, 1, 0])

clf = AnDE(n_dependence=1, n_bins=2)
clf.fit(X_xor, y_xor)
print(clf.predict(X_xor))  # [0, 1, 1, 0] ✓

Installation

pip install scikit-bayes

Or install from source:

pip install git+https://github.com/ptorrijos99/scikit-bayes.git

Documentation

Development

This project uses pixi for environment management.

# Run tests
pixi run test

# Run linter
pixi run lint

# Build documentation
pixi run build-doc

# Activate development environment
pixi shell -e dev

Citation

If you use scikit-bayes in a scientific publication, please cite:

@software{scikit_bayes,
  author = {Torrijos, Pablo},
  title = {scikit-bayes: Bayesian Network Classifiers for Python},
  year = {2025},
  url = {https://github.com/ptorrijos99/scikit-bayes}
}

References

  • Webb, G. I., Boughton, J., & Wang, Z. (2005). Not so naive Bayes: Aggregating one-dependence estimators. Machine Learning, 58(1), 5-24.
  • Flores, M. J., Gámez, J. A., Martínez, A. M., & Puerta, J. M. (2009). GAODE and HAODE: Two proposals based on AODE to deal with continuous variables. ICML '09, 313-320.
  • Zaidi, N. A., Webb, G. I., Carman, M. J., & Petitjean, F. (2017). Efficient parameter learning of Bayesian network classifiers. Machine Learning, 106(9-10), 1289-1329.

License

BSD-3-Clause. See LICENSE for details.

Metadata

Release files for scikit-bayes 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scikit-bayes 1.2.1
File Size Uploaded
scikit_bayes-1.2.1.tar.gz 172.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for scikit-bayes 1.2.1
File Interpreter ABI Platform
scikit_bayes-1.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 215.8 kB

Release files / scikit_bayes-1.2.1.tar.gz

Download URL scikit_bayes-1.2.1.tar.gz
Size 172.4 kB
Tags Source
SHA-256 checksum
How to use checksums
2e879b6a073e476b564ef7e2fbdab4269308aff2f88dc26eda1c4e7e08e21acd
BLAKE2b-256 checksum
How to use checksums
760cbcb9a309cecfc934c09491f08dd87aac7ceb7f27b8a62d083b44d18639ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.

Transparency log

Release files / scikit_bayes-1.2.1-py3-none-any.whl

Download URL scikit_bayes-1.2.1-py3-none-any.whl
Size 43.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cedab2bd0e0564c8e1d64eeb13e4170b62dff4899f35fe2fca1cf7ebd951d3e8
BLAKE2b-256 checksum
How to use checksums
0cade34a51d30f438e22633f13291c1a14ca7c0c1bf7d0ce098300a11fe9d71a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.2.1 This release

2 release files

1.0.0

2 release files

0.1.3

2 release files

0.1.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page