Nous: A Neuro-Symbolic Library for Interpretable AI
Project description
Nous — A Neuro-Symbolic Library for Interpretable AI
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nous-0.4.0.tar.gz.
File metadata
- Download URL: nous-0.4.0.tar.gz
- Upload date:
- Size: 42.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e0396752e354ae499e8981477b2e5593125f813712d3f8d9c57e14895848402
|
|
| MD5 |
4e4dfaf83f6f9765840e49fe841fc340
|
|
| BLAKE2b-256 |
9e41653e6da4c177f645bd24b1d0718ed5302fb76ae57540aa4aafc9357746b8
|
File details
Details for the file nous-0.4.0-py3-none-any.whl.
File metadata
- Download URL: nous-0.4.0-py3-none-any.whl
- Upload date:
- Size: 52.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38318d090c6de10877fdffa1f7d25d7cbaef7e19af1ef83b131eebee21db80c7
|
|
| MD5 |
642c0ceb85501c788689d84b3bd37469
|
|
| BLAKE2b-256 |
e7ac1587fd6ebb8c495660c11df548fb7eb4735d965aa927807ee6d22743282f
|