Skip to main content

scikit-bayes

tests codecov doc Python DOI License

scikit-bayes adds Bayesian network classifiers to scikit-learn. Every model follows the scikit-learn estimator API, so it works in pipelines, cross-validation and grid search, and takes tables that mix continuous, categorical and binary attributes. Counting and prediction run in compiled Numba kernels.

Models

  • MixedNB: Naive Bayes with Gaussian, categorical and Bernoulli attributes in one model.
  • AnDE: Averaged n-Dependence Estimators (AODE, A2DE), pooled with the arithmetic or the geometric mean.
  • WeightedAnDE: AnDE with discriminative weights, one per component or one per factor of each component (the weighted CCBN of Zaidi et al., 2017), at four levels of granularity, fitted jointly or one component at a time (which gives the AnDEw of FedAnDE).
  • AnJE and ALR: Averaged n-Join Estimators and Accelerated Logistic Regression as defined by Zaidi et al. (2016), trained by default with the protocol of the paper.
  • 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, with a Chow-Liu tree of attribute dependencies.
  • KDB: K-Dependence Bayesian classifier, in which every attribute has at most k attribute parents chosen by conditional mutual information.
  • MDLPDiscretizer and DecisionTreeDiscretizer: supervised discretization of continuous attributes, to place before a model in a pipeline.

Quick start

import numpy as np
from skbn import MixedNB, AnDE

# A Gaussian, a binary and a categorical column; the types are inferred
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]]))  # [1]

# XOR, which Naive Bayes cannot learn
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

The development version installs from GitHub:

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

Documentation

  • User guide: how each model is defined and estimated, and how to choose its parameters.
  • API reference: parameters, attributes and methods of every class.
  • Example gallery: what each model captures, shown on small datasets with plots.

Development

The development environments are managed with pixi:

# 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},
  doi = {10.5281/zenodo.23950884},
  url = {https://github.com/ptorrijos99/scikit-bayes}
}

The DOI always resolves to the latest version; every release also has its own DOI on Zenodo (1.3.0: 10.5281/zenodo.23950885). 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.2

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.3.2
File Size Uploaded Provenance Actions
scikit_bayes-1.3.2.tar.gz 265.5 kB With provenance Details for scikit_bayes-1.3.2.tar.gz

Built distribution (wheel)

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

Total release size: 385.4 kB

Release files / scikit_bayes-1.3.2.tar.gz

Download URL scikit_bayes-1.3.2.tar.gz
Size 265.5 kB
Tags Source
SHA-256 checksum
How to use checksums
6bb2383c50a125d73f7e964b4fd52563b0a5662b29e95387c6d32730e22bc906
BLAKE2b-256 checksum
How to use checksums
53edd7443728222f2b4d7558827669b2a47f0f89c3ef757b8112c326533d5263
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 6, 2026.

Transparency log

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

Download URL scikit_bayes-1.3.2-py3-none-any.whl
Size 119.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b1f9f4f93f2e1984f4bc2ea17ebf95427b335115f36a5968bdc67e0fd4084928
BLAKE2b-256 checksum
How to use checksums
98f6753adc72a853b7dca5596327506c642a963a7400c7d12482c5a8c7b93f5e
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 6, 2026.

Transparency log

Security for scikit-bayes 1.3.2

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.

Select from 2 files

Attestation for scikit_bayes-1.3.2.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 6, 2026.

Transparency log

A 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.

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