Skip to main content

A Python package for AnDE classifiers.

Project description

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.

Project details


Download files

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

Source Distribution

scikit_bayes-0.1.2.tar.gz (135.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scikit_bayes-0.1.2-py3-none-any.whl (26.6 kB view details)

Uploaded Python 3

File details

Details for the file scikit_bayes-0.1.2.tar.gz.

File metadata

  • Download URL: scikit_bayes-0.1.2.tar.gz
  • Upload date:
  • Size: 135.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for scikit_bayes-0.1.2.tar.gz
Algorithm Hash digest
SHA256 992cb316d455736d7c6c0df42ec8441cef6c363d044826fa55f8f2bbb8af7de3
MD5 6e658bdb62d86c076803f1f16a343ab0
BLAKE2b-256 dde612fe8981025739df523116be6f9b9e4e33dfe678bfccb2cf90c3d9ac6037

See more details on using hashes here.

Provenance

The following attestation bundles were made for scikit_bayes-0.1.2.tar.gz:

Publisher: publish.yml on ptorrijos99/scikit-bayes

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file scikit_bayes-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: scikit_bayes-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 26.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for scikit_bayes-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 abe0b925cbb819f65bea81fe5621f5aae43bbc59bbc9c7727e4815223122a0b2
MD5 8ee015506059890f96bc7f7e1dd6ae67
BLAKE2b-256 492b1ecb35333b4987b79fd6f7172b0b2a58138b969d31fcbaa663c907f385b0

See more details on using hashes here.

Provenance

The following attestation bundles were made for scikit_bayes-0.1.2-py3-none-any.whl:

Publisher: publish.yml on ptorrijos99/scikit-bayes

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page