This release is a pre-release and may not be stable for production use.
costream: A Streaming Evaluation Protocol
Evaluate sparse-event detectors on continuous signals the way they are deployed.
Sparse-event detectors are commonly evaluated on presegmented windows: windows cut around annotated events, compared against windows sampled from event-free signal. A deployed detector has no such luxury. It must process an unsegmented signal continuously, find events whose locations are unknown, and avoid false alarms.
costream is a Python package that evaluates window-based detectors under those conditions. Overlapping window scores are aggregated into a temporal confidence map and thresholded into detection episodes. Each episode emits one timestamped event, which is scored against the annotation. This makes measurable what presegmented evaluation cannot: false alarms over elapsed monitoring time, detection delay and operating-point trade-offs. costream was developed and evaluated on wearable fall detection. Its defaults come from that application, and the protocol is not specific to it.
Paper: costream: A Streaming Evaluation Protocol for Wearable Fall Detection (AICS 2026). arXiv:2509.11789
How it works
- Window scoring. A trained classifier scores successive overlapping windows of a continuous signal.
- Temporal aggregation. Scores are combined by pointwise maximum into a temporal confidence map.
- Detection episodes. Thresholding gives contiguous episodes, and episodes closer than
debounce_secsmerge into one. - Event evaluation. Each episode emits one detection, scored against the annotated event.
Install
pip install costream
This installs numpy, pandas, scikit-learn, imbalanced-learn, joblib, matplotlib and seaborn. The model roster used in the paper (Catch22, MiniRocket, QUANT, ResNet) is optional and includes TensorFlow:
pip install "costream[models]"
Python 3.10 or newer. The package is tested on 3.10.
Quickstart
1. Prepare your data
costream needs, for each recording, a signal and event labels, grouped by subject so that cross-validation can split on subjects. You need at least as many subjects as folds.
Signal and labels. make_csv_loader reads one CSV per recording. feature_cols names the signal column or columns, and label_col (default "label") names the label column: 0 for background, non-zero from the annotated event. The first sample of each contiguous non-zero block is taken as the event position f. Use new_features={"mag": fn} to derive a column such as a magnitude from raw axes, and any pandas.read_csv option (header, names, and so on) is passed through. If your files carry no label column, supply a label_extractor(df, path) -> df that adds one, for example from the file name.
Grouping by subject. group_files_by_subject(directory) returns {subject_id: [paths]}. By default the subject id is the part of the file name before the first underscore or hyphen, so s01_rec2.csv belongs to subject s01. For other naming schemes, pass an id_extractor that takes a pathlib.Path and returns the id, and use file_pattern to select files.
# Files named like "rec2_P01.csv": the subject id is the last token.
groups = group_files_by_subject(
"data/", id_extractor=lambda p: p.stem.split("_")[-1]
)
# Illustration: the event sample is encoded in the file name, "P01_rec2_f120000.csv".
def label_from_name(df, path):
f = int(path.stem.split("_f")[-1])
df["label"] = 0
df.loc[f, "label"] = 1
return df
load = make_csv_loader(feature_cols=["mag"], label_col="label",
label_extractor=label_from_name)
2. Run an evaluation
from sklearn.ensemble import ExtraTreesClassifier
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler
from costream.data import group_files_by_subject, make_csv_loader
from costream.evaluation import ModelSpec, run_subject_cv
groups = group_files_by_subject("data/") # {subject_id: [csv paths]}
load = make_csv_loader(feature_cols=["mag"], label_col="label")
subject_map = {sid: load(paths) for sid, paths in groups.items()}
specs = [ModelSpec(name="ExtraTrees", estimator=make_pipeline(
StandardScaler(), ExtraTreesClassifier(n_estimators=150, random_state=0)))]
results = run_subject_cv(
subject_map, specs,
feature_cols=["mag"], label_col="label",
cv=5, window_size=10.0, step=1.0, freq=100,
activity_threshold=1.4, spacing="multiphase",
tolerance=20.0, debounce_secs=60.0, resample=False,
)
print(results[["model", "protocol", "fold", "tp", "fp", "fn", "f1-score"]])
Any scikit-learn-style classifier with fit and predict_proba works. scripts/smoke_test.py runs the same pipeline end to end on synthetic data.
What it computes
run_subject_cv evaluates every model under both protocols in the same folds. Each row of results is one model, fold and protocol, at threshold 0.5, with the protocol in the protocol column. See results.columns for the full list.
- Protocol B (streaming) is costream's protocol. The detector scores every window of the continuous recording, scores are aggregated into a confidence map, and each detection episode is scored against the annotation.
- Protocol A (presegmented) is the conventional baseline: a window at the annotated event against windows from event-free signal. It is included so you can see whether the two ways of evaluating lead to the same conclusions.
The protocols measure different quantities, so compare rankings across them, not absolute scores. In the fall-detection study they agreed on the best method overall but chose different methods in 6 of 20 model-window configurations.
costream.evaluation.evaluate_recording scores a single recording, and threshold sweeps from cached window scores are in scripts/run_tau_sweep.py (see the paper for the cost-sensitive threshold analysis).
Configuration
| Parameter | Meaning | Default |
|---|---|---|
window_size |
window length in seconds | 7.0 (the paper uses 3, 10, 30 and 60) |
step |
window step in seconds | 1.0 |
freq |
sampling rate in Hz | 100 |
activity_threshold |
admissibility gate, in the units of mag: a window is admissible only if its peak between one and two seconds from its start exceeds it |
1.4 |
tolerance |
t in the reference interval [f - 1, f + t) seconds, where f is the annotated event |
20 |
debounce_secs |
detections closer than this merge into one episode | 60 |
exclusion_tolerance |
negative windows are drawn outside [f - (window_size + t), f + t) |
20 |
Inadmissible windows are excluded from the negative training set and score zero at inference. The defaults come from wearable fall detection, and 1.4 assumes acceleration in g. For other signals or events, set activity_threshold, tolerance and debounce_secs to suit the signal and the expected event duration. If the gate drops every negative window, training fails with a single-class error.
Reproducing the paper
The notebook, scripts and results live in the repository, not in the installed package.
reproduce_paper.ipynb shows every table and figure from the paper, rendered on the page, without running anything and without access to FARSEEING. To rerun it, which reads only the CSVs under results/ and needs no model refitting:
pip install -r requirements.txt
pip install -e .
jupyter notebook reproduce_paper.ipynb
To regenerate the results from scratch, place FARSEEING at data/farseeing.feather and run:
python scripts/run_sweep.py
FARSEEING is available from its maintainers on request. Its loader is scripts/farseeing_loader.py. To check an installation without FARSEEING:
python scripts/smoke_test.py
This runs the full pipeline on fabricated data, not real falls, to confirm that the install works. The exact versions used for the paper are pinned in requirements.txt (Python 3.10.18).
Citation
@inproceedings{aderinola2026costream,
title = {costream: A Streaming Evaluation Protocol for Wearable Fall Detection},
author = {Aderinola, Timilehin B. and D'Ascanio, Ilaria and Palmerini, Luca and Chiari, Lorenzo and Klenk, Jochen and Becker, Clemens and Caulfield, Brian and Ifrim, Georgiana},
booktitle = {Proceedings of the Irish Conference on Artificial Intelligence and Cognitive Science (AICS 2026)},
series = {Proceedings of Machine Learning Research},
year = {2026}
}
The proceedings volume and pages will be added when published.
Licence
MIT. See LICENSE.
Acknowledgements
This work was supported by Research Ireland under the Government of Ireland Postdoctoral Fellowship Programme (Grant Number: GOIPD/2025/1434).
Metadata
Release files for costream 0.1.0rc2
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 |
|---|---|---|---|---|
| costream-0.1.0rc2.tar.gz | 41.3 kB | Without provenance | Details for costream-0.1.0rc2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| costream-0.1.0rc2-py3-none-any.whl | Python 3 | none | any | Details for costream-0.1.0rc2-py3-none-any.whl |
Total release size: 86.5 kB
Release files / costream-0.1.0rc2.tar.gz
| Download URL | costream-0.1.0rc2.tar.gz |
|---|---|
| Size | 41.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
006dfaec014b1b11388e4ef267321033a485c8093645e8e6a94f648476d66ea7
|
|
BLAKE2b-256 checksum How to use checksums |
740f4c7a484789fc6735442a06a0c1531123e1779ba4d6a449621945fd054df6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / costream-0.1.0rc2-py3-none-any.whl
| Download URL | costream-0.1.0rc2-py3-none-any.whl |
|---|---|
| Size | 45.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
46ec386f1f139df5bb850c214fd3567afd7349d49408679fcc8d9ca698386a94
|
|
BLAKE2b-256 checksum How to use checksums |
c62e4d7f70a1793ec6ed270f35a6124888be362d5ad26b5934e7432f13856921
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for costream 0.1.0rc2
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.