scikit-bayes
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, pooled with the arithmetic or the geometric mean
- WeightedAnDE: AnDE with discriminative weights, one per component or one per factor of each component (weighted CCBN), at four levels of granularity, fitted jointly or one component at a time (the AnDEw of FedAnDE)
- AnJE and ALR: Averaged n-Join Estimators and Accelerated Logistic Regression, as defined by Zaidi et al. (2016), with the training protocol of the paper by default
- GaussianAnJE and GaussianALR: AnJE and ALR built on the factors of the SPnDEs, so that continuous attributes keep Gaussian conditionals as in HAODE
- TAN: Tree Augmented Naive Bayes, a tree of attribute dependencies learned with the Chow-Liu procedure
- KDB: K-Dependence Bayesian classifier, in which every attribute has at most k attribute parents chosen by conditional mutual information
- 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
- 📖 User Guide - Detailed documentation
- 📚 API Reference - Complete API docs
- 🎨 Examples Gallery - Visual examples
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 and Alcarria Laserna, {\'O}scar and G{\'a}mez, Jos{\'e} A. and Puerta, Jos{\'e} M.},
title = {scikit-bayes: Bayesian Network Classifiers for Python},
year = {2026},
url = {https://github.com/ptorrijos99/scikit-bayes}
}
The same information is in CITATION.cff, which GitHub shows as "Cite this repository".
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., & Cerquides, J. (2016). ALR^n: Accelerated higher-order logistic regression. Machine Learning, 104(2-3), 151-194.
- Zaidi, N. A., Webb, G. I., Carman, M. J., Petitjean, F., Buntine, W., Hynes, M., & De Sterck, H. (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.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| scikit_bayes-1.3.0.tar.gz | 244.1 kB | With provenance | Details for scikit_bayes-1.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| scikit_bayes-1.3.0-py3-none-any.whl | Python 3 | none | any | Details for scikit_bayes-1.3.0-py3-none-any.whl |
Total release size: 343.8 kB
Release files / scikit_bayes-1.3.0.tar.gz
| Download URL | scikit_bayes-1.3.0.tar.gz |
|---|---|
| Size | 244.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
477220ea5008f5a8b4483fc8b6e515b4b7cc624197732a6403f335c0500fa1f7
|
|
BLAKE2b-256 checksum How to use checksums |
b7dceb21ffe0678a708e46ac1453b8a5a893f7bc2e8b93440c6864cca6d317e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 4, 2026.
Transparency logRelease files / scikit_bayes-1.3.0-py3-none-any.whl
| Download URL | scikit_bayes-1.3.0-py3-none-any.whl |
|---|---|
| Size | 99.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ba2c6415aef172baadc2d98c99de43ef5d61194237cd0e035b35f5e20857c205
|
|
BLAKE2b-256 checksum How to use checksums |
856285abaac3d63c9e02f50e50065ff3a889fd19953f0fac24e6110ceaa4eca2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 4, 2026.
Transparency logSecurity for scikit-bayes 1.3.0
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for scikit_bayes-1.3.0.tar.gz
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 Nov 4, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.