A Python library for Random Set Neural Networks with uncertainty estimation
Project description
R3ALAI
Python SDK for Random Set Neural Networks (RSNN): uncertainty estimation, conformal prediction, and active learning. Built to add RSNN benefits (sample efficiency, robustness, reliability) to ML workflows.
Install
- Base:
pip install r3alai - With vision backbones:
pip install 'r3alai[vision]' - With YOLO:
pip install 'r3alai[yolo]'
Requires Python 3.8+ and PyTorch.
What it provides
r3alai.models:RSNNClassifier— RSNN head on a backbone (torchvision or customnn.Module).r3alai.conformal:ConformalPredictor— confidence sets with distribution-free coverage after calibration.r3alai.active_learning:ActiveLearner— entropy/credal querying and simple disagreement mode.r3alai.utils:RSNNYOLOWrapper,YOLOFeatureExtractor— plug RSNN uncertainty into YOLOv8.
How to use (high-level)
- Create an RSNN model
- Pick a backbone:
"resnet50","mobilenet_v2","efficientnet_b0", or use a custom backbone. - Set
n_classes(one-hot labels expected). Optionalalpha/betaregularization.
- Train
- Call
fit(X, y, ...)with tensors/ndarrays; early stopping and LR scheduling are included.
- Predict with uncertainty
- Call
predict(..., return_uncertainty=True)to get predictions, pignistic entropy, and credal width.
Conformal prediction
- Wrap a trained RSNN with
ConformalPredictor(confidence_level=0.9/0.95). - Calibrate on a held-out split (features and one-hot labels).
- Use
predictfor confidence sets;get_coverageto measure empirical coverage.
Active learning
- Construct
ActiveLearner(model, uncertainty_measure="entropy"|"credal"). - Provide an unlabeled pool to
queryto select samples and indices for annotation.
YOLO integration (optional)
- Install extras:
r3alai[yolo]. - Initialize
RSNNYOLOWrapper(yolo_model_path, n_classes). - Train with your DataLoaders; optionally calibrate conformal and then predict with uncertainty or confidence sets.
Custom backbones and frameworks
- Custom
nn.Module: setbase_model="custom", assign your module torsnn_model.base_model, then callset_belief_layer(feature_dim). - Hugging Face models: adapt outputs to a 512-dim feature vector and connect as a custom backbone.
Tips
- Keep a small calibration split to enable conformal coverage.
- Start active learning with entropy querying; try disagreement for harder pools.
- For detection, first freeze the YOLO backbone and train only the RSNN head.
Support
- See docstrings on
RSNNClassifier,ConformalPredictor,ActiveLearner, andRSNNYOLOWrapper. - Report issues and requests on GitHub Issues.
License
MIT
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 r3alai-0.1.3.tar.gz.
File metadata
- Download URL: r3alai-0.1.3.tar.gz
- Upload date:
- Size: 14.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
63a27a58cc2ab554259b751e5722152ff3dcc839d7c037a3c084e6e9adb8ff4d
|
|
| MD5 |
ea645c341faaf560e51d17e917ba1206
|
|
| BLAKE2b-256 |
564ae78230b865599cb6ab62c8dfb89f2165ffab6ce3db248361cae167e56196
|
Provenance
The following attestation bundles were made for r3alai-0.1.3.tar.gz:
Publisher:
publish.yml on R3AL-AI/package
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
r3alai-0.1.3.tar.gz -
Subject digest:
63a27a58cc2ab554259b751e5722152ff3dcc839d7c037a3c084e6e9adb8ff4d - Sigstore transparency entry: 464835481
- Sigstore integration time:
-
Permalink:
R3AL-AI/package@6ec173df8e88b065f387806068e32483c09234f0 -
Branch / Tag:
refs/tags/v0.1.6 - Owner: https://github.com/R3AL-AI
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6ec173df8e88b065f387806068e32483c09234f0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file r3alai-0.1.3-py3-none-any.whl.
File metadata
- Download URL: r3alai-0.1.3-py3-none-any.whl
- Upload date:
- Size: 16.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5755dcc7457a85c85c30ed27ce09c4e29af250e1976bfec1d5caa60e5df9d68
|
|
| MD5 |
2fab9f6248e3dfc6e4071427ec9a6cf1
|
|
| BLAKE2b-256 |
a210227d24f8d7091c33524eef340c5356be4eae88cc7c33f6fbd06dd27e0137
|
Provenance
The following attestation bundles were made for r3alai-0.1.3-py3-none-any.whl:
Publisher:
publish.yml on R3AL-AI/package
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
r3alai-0.1.3-py3-none-any.whl -
Subject digest:
a5755dcc7457a85c85c30ed27ce09c4e29af250e1976bfec1d5caa60e5df9d68 - Sigstore transparency entry: 464835553
- Sigstore integration time:
-
Permalink:
R3AL-AI/package@6ec173df8e88b065f387806068e32483c09234f0 -
Branch / Tag:
refs/tags/v0.1.6 - Owner: https://github.com/R3AL-AI
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6ec173df8e88b065f387806068e32483c09234f0 -
Trigger Event:
push
-
Statement type: