pbp-anomaly
Training-free anomaly detection in environmental sensor networks via pseudo-Boolean polynomial (PBP) decomposition.
Reference implementation of the PBP anomaly scoring described in:
T. M. Chikake and B. Goldengorin, "Pseudo-Boolean polynomial anomaly scoring for intelligent multisensor environmental monitoring," in International Conference on Advanced Sensing and Intelligent Systems (ICASIS 2026), Proc. SPIE 14309, 2026. https://doi.org/10.1117/12.3121130
The repository also contains the multi-dataset experiments of an extended study.
Install
pip install pbp-anomaly
This also installs the PBP core, tmc-pbp (imported as pbp).
Quick start (reproducing the experiments)
git clone https://github.com/Tenfleques/pbp-anomaly.git
cd pbp-anomaly
pip install -e ".[all]"
# Download large datasets (Beijing, NOAA weather stations)
python experiments/download_data.py
# Verify pre-computed results (should report 200+ PASS, 0 FAIL)
python experiments/verify_consistency.py
# Generate all figures
python experiments/generate_figures.py
What this repo contains
pbp_anomaly/-- Python package implementing the PBP anomaly detectordata/-- Small datasets shipped with the repo (UCI, OpenMeteo); large datasets downloaded via scriptresults/precomputed/-- Pre-computed experiment results (JSON/CSV) for instant verificationexperiments/-- Scripts to reproduce all results and figures from the papertests/-- Unit tests (27 tests)
Datasets
The paper evaluates PBP across 9 datasets spanning two sensor domains:
| Dataset | Domain | Sensors | Readings | Source | Shipped |
|---|---|---|---|---|---|
| UCI Air Quality (Italy) | Air quality | 8 | 9,357 | UCI MLR | Yes |
| Beijing Dongsi | Air quality | 10 | 35,064 | Zhang et al. 2017 | Download |
| EPA AQS (Los Angeles) | Air quality | 4 | 26,280 | EPA AQS | Optional |
| Sao Paulo (CAMS) | Air quality | 6 | 17,520 | Open-Meteo | Yes |
| Cape Town (CAMS) | Air quality | 6 | 17,520 | Open-Meteo | Yes |
| Chicago O'Hare | Weather | 6 | 17,520 | NOAA ISD | Download |
| Miami | Weather | 6 | 17,520 | NOAA ISD | Download |
| San Francisco | Weather | 6 | 17,520 | NOAA ISD | Download |
| Fairbanks | Weather | 6 | 17,520 | NOAA ISD | Download |
"Shipped" means the CSV is included in this repo. "Download" means download_data.py fetches it automatically.
Reproducing results
Verify pre-computed results
python experiments/verify_consistency.py
This checks every number cited in the manuscript against the pre-computed result files in results/precomputed/. No data download required.
Full replication from raw data
# Download datasets
python experiments/download_data.py
# Run all experiments (may take several hours)
python experiments/replicate_all.py --output-dir results/local
# Verify fresh results
python experiments/verify_consistency.py --results-dir results/local
# Generate figures from fresh results
python experiments/generate_figures.py --results-dir results/local
For a quick smoke test on a single dataset:
python experiments/replicate_all.py --datasets UCI --quick --output-dir results/local
Figures
python experiments/generate_figures.py
Generates Fig 1 (temporal robustness), Fig 2 (hub variable heatmap), and Fig 3 (sensor-pair z-score case study) in figures/.
Library usage
from pbp_anomaly import AnomalyDetector
import pandas as pd
df = pd.read_csv('your_sensor_data.csv')
detector = AnomalyDetector(window_size=6, mode='both')
result = detector.fit_score(df, sensor_cols=['CO', 'NO2', 'O3'])
print(f"AUC-ROC: {result['standard']['auc_roc']:.3f}")
print(f"Top sensor pairs: {result['pair_ranking'][:3]}")
Or via CLI:
pbp-anomaly detect data.csv --sensors CO,NO2,O3 --mode both
Running tests
pytest tests/ -v
Dependencies
Core: numpy, pandas, scipy, scikit-learn, tmc-pbp (Python >= 3.10)
Optional: matplotlib (figures), requests (NOAA download), pytest (tests)
All installed automatically via pip install -e ".[all]".
Citation
@inproceedings{Chikake2026icasis,
author = {Chikake, Tendai M. and Goldengorin, Boris},
title = {Pseudo-Boolean polynomial anomaly scoring for intelligent multisensor environmental monitoring},
booktitle = {International Conference on Advanced Sensing and Intelligent Systems (ICASIS 2026)},
series = {Proc. SPIE},
volume = {14309},
publisher = {SPIE},
year = {2026},
doi = {10.1117/12.3121130}
}
License
MIT
Metadata
Release files for pbp-anomaly 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pbp_anomaly-0.2.0.tar.gz | 17.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pbp_anomaly-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 31.0 kB
Release files / pbp_anomaly-0.2.0.tar.gz
| Download URL | pbp_anomaly-0.2.0.tar.gz |
|---|---|
| Size | 17.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9cbc8d58d2b60ea1b95334bfe5804c6bd745e407bfde94a677d9da73939164e1
|
|
BLAKE2b-256 checksum How to use checksums |
94b842b44b662dbf2c5c98e60a22be2de9dc73ba377b5372f1aecb55c07d9353
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.21
|
Release files / pbp_anomaly-0.2.0-py3-none-any.whl
| Download URL | pbp_anomaly-0.2.0-py3-none-any.whl |
|---|---|
| Size | 14.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7d29bf1e986d7e35214ae4854e366f3e19f0f0377d59aa9b97cdc66a2d27411a
|
|
BLAKE2b-256 checksum How to use checksums |
c1fc326032faf97bc460bade5dbfd849c2f37a3bd78615e92eec5542806e94b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.21
|