Behavior Learning (BL)
Behavior Learning (BL) is a general-purpose machine learning framework grounded in behavioral science. It unifies predictive performance and intrinsic interpretability within a single modeling paradigm. BL learns explicit optimization structures from data by parameterizing a compositional utility function built from interpretable modular blocks. Each block represents a Utility Maximization Problem (UMP), a foundational framework of decision-making and optimization. BL supports architectures ranging from a single UMP to hierarchical compositions, enabling expressive yet structurally transparent models. Unlike post-hoc explanation methods, BL provides interpretability by design while maintaining strong empirical performance on high-dimensional tasks.
Installation
blnetwork can be installed via PyPI or directly from GitHub.
Pre-requisites:
Python 3.10.9 or higher
pip
For developers
git clone https://github.com/MoonYLiang/Behavior-Learning.git
cd blnetwork
pip install -e .
Installation via github
pip install git+https://github.com/MoonYLiang/Behavior-Learning.git
Installation via PyPI:
pip install blnetwork
Requirements
# python==3.10.9
torch>=2.2
numpy>=1.26
pandas>=2.0
After activating the virtual environment, you can install specific package requirements as follows:
pip install -r requirements.txt
Optional: Conda Environment Setup For those who prefer using Conda:
conda create --name blnetwork-env python=3.10.9
conda activate blnetwork-env
pip install git+https://github.com/MoonYLiang/Behavior-Learning.git # For GitHub installation
# or
pip install blnetwork # For PyPI installation
Computation Requirements
BL is implemented in PyTorch and supports both CPU and GPU training.
- Small-scale tabular examples run on a single CPU within a few minutes.
- High-dimensional settings may benefit from GPU acceleration (e.g., NVIDIA L40).
For most tabular tasks, CPU training is sufficient.
Examples
Start with the notebooks in examples/:
You need to install scikit-learn>=1.3 to run Examples
Important Hyperparameters
-
hidden_dims: BL backbone architecture (depth of BL blocks). Similar to MLP hidden sizes, though BL often requires smaller widths. -
first_act_func: U-block activation function (e.g.,tanh,"none").
Controls the nonlinearity of the utility term.
tanhintroduces diminishing marginal effects, while"none"keeps it linear. -
second_act_func/third_act_func: C-/T-block activation functions.
Shape the constraint structures of the learned optimization landscape. -
constrain_lambda: λ positivity constraint.
If enabled, enforces λ > 0. -
export_cfg: model structure export configuration.
Controls exporting a structured.txtsummary of model parameters. Acceptsdf/feature_namesto align learned parameters with input variable names for interpretability.
Other training hyperparameters (optimizer, learning rate, batch size, weight decay, early stopping, etc.) can generally be tuned similarly to standard MLPs.
Advice on hyperparameter tuning
In many cases, BL can achieve comparable (or slightly better) performance than an MLP baseline using roughly one third of the hidden width.
Other hyperparameters can be initialized based on standard MLP tuning, and then refined for the specific task.
Contact
If you have any questions, please contact yue.liang@student.uni-tuebingen.de
Metadata
Release files for blnetwork 0.1.1
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 |
|---|---|---|---|---|
| blnetwork-0.1.1.tar.gz | 19.0 kB | Without provenance | Details for blnetwork-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| blnetwork-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for blnetwork-0.1.1-py3-none-any.whl |
Total release size: 40.0 kB
Release files / blnetwork-0.1.1.tar.gz
| Download URL | blnetwork-0.1.1.tar.gz |
|---|---|
| Size | 19.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ce865e9abbb23468e05dd6ec21a906c8092bb65be115f6c55a1c8f31c7bdb63d
|
|
BLAKE2b-256 checksum How to use checksums |
541bb431579424fa1aea0aa25ac9f79c3eb4cbe47fa3052651a78de57981ea95
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.9
|
Release files / blnetwork-0.1.1-py3-none-any.whl
| Download URL | blnetwork-0.1.1-py3-none-any.whl |
|---|---|
| Size | 21.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ddab9c97e455533f0d60635e2cda2b57bffb2d75629861c95ffe214ba7351cd1
|
|
BLAKE2b-256 checksum How to use checksums |
defebb9a5a023758f3879b497fa3da986a4918ad066b0f2062ac1ddfb5c74a1a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.9
|
Security for blnetwork 0.1.1
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.