Skip to main content

Nous: A Neuro-Symbolic Library for Interpretable AI

Project description

Nous — A Neuro-Symbolic Library for Interpretable AI

PyPI License

Make tabular models you can read.
Nous learns compact logical rules and optional case‑based prototypes inside one differentiable model — so prediction and explanation come from the same place.

  • 🧩 One white‑box → two styles: rules and/or prototypes
  • 🔀 Learned AND / OR / k‑of‑n mixtures capture interactions without bloat
  • ✂️ Minimal, faithful stories: pruning + sufficiency/comprehensiveness checks
  • 🚀 Practical: competitive accuracy, NumPy export, unit‑tested toolkit

Key Features

  • Intrinsic interpretability (not post‑hoc): explanations are part of the forward pass
  • Switchable style: enable/disable prototypes; choose rule selection (fixed / softmax / sparse); add calibrators
  • Fidelity diagnostics: pruned‑forward inference, minimal‑sufficient explanations, stability tools
  • Ready to ship: pure‑NumPy export for inference without PyTorch

Installation

# Stable from PyPI
pip install nous

# With example extras (plots, progress, UCI fetchers)
pip install "nous[examples]"

# Dev setup (tests, linters, type checks)
pip install "nous[dev]"

Requirements (core):

  • Python 3.9+
  • torch>=2.1
  • numpy>=1.22
  • pandas>=1.5
  • scikit-learn>=1.2

Extras:

  • examples: matplotlib>=3.6, seaborn>=0.12, tqdm>=4.65, ucimlrepo>=0.0.5
  • dev: pytest>=7.0, pytest-cov>=4.0, mypy>=1.5, ruff>=0.5, black>=23.0, matplotlib>=3.6, seaborn>=0.12, tqdm>=4.65, ucimlrepo>=0.0.5

Recommended Configurations

Profile Rule selection Calibrators Prototypes Use when Speed
Fast baseline fixed off off quick sweeps, ablations ⚡⚡⚡
Default rules softmax on off general use, strong accuracy ⚡⚡
Explain‑everything softmax on on rich case‑based narratives

Tips:

  • Train with prototypes off for speed; enable them only on the final model if you need case‑based stories.
  • 300 epochs with patience≈50 works well on common tabular datasets.

Bench Snapshot (5‑fold CV, typical)

Dataset Metric Nous (rules) Nous (+proto) EBM XGBoost
HELOC (cls) AUC ~0.791 ~0.792 ~0.799 ~0.796
Adult (cls) AUC ~0.913 ~0.914 ~0.926 ~0.929
Breast Cancer (cls) Acc ~0.975 ~0.983 ~0.970 ~0.965
California (reg) RMSE ~0.514 ~0.505 ~0.562 ~0.439

Numbers vary with seed/HPO. See examples/benchmark.ipynb for reproducible runs.

What makes Nous different?

  • The explanation is the model: rules and prototypes live in the forward pass
  • Interactions without clutter: AND/OR/k‑of‑n mixtures keep explanations short
  • Verified stories: minimal‑sufficient explanations + pruned‑forward confidence checks
  • Lightweight deployment: NumPy export (no torch at inference)

Repository Layout

  • examples/
    • benchmark.ipynb — end‑to‑end comparison on classic tabular data
    • wine_classification.py, california_regression.py — minimal scripts
    • export_numpy_demo.py — deploy without torch
  • nous/
    • model.py (NousNet), facts.py (calibrated L−R facts)
    • rules/* (fixed/softmax/sparse), explain/* (pruning, fidelity, traces, prototypes)
    • training/* (loop, schedulers), export/* (NumPy), utils/*
  • tests/ — unit tests for forward, rules, facts, prototypes, explanations, export

License

MIT — see LICENSE.

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

nous-0.3.0.tar.gz (36.6 kB view details)

Uploaded Source

Built Distribution

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

nous-0.3.0-py3-none-any.whl (47.5 kB view details)

Uploaded Python 3

File details

Details for the file nous-0.3.0.tar.gz.

File metadata

  • Download URL: nous-0.3.0.tar.gz
  • Upload date:
  • Size: 36.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for nous-0.3.0.tar.gz
Algorithm Hash digest
SHA256 68b246089c074ef04bae0907b501aeeefd48d2facdac5f7e97c2ee3a6b95fb24
MD5 eac443085fb1b0eae7c5cd0626330216
BLAKE2b-256 aae3550c8379927230e108790ef16d5ae1fa22bb42da9917e53278c554513976

See more details on using hashes here.

File details

Details for the file nous-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: nous-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 47.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for nous-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 507b5d5d0a36291275066d02f8de403478c1e71ced4b10796b8ba7bf329ad8c1
MD5 2e7a4729863847652f58157d6ced61d3
BLAKE2b-256 98aaefbba7e795dbac80c09ae18fd547c81a819ce2f9369c604f83a63e427fcc

See more details on using hashes here.

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