Skip to main content

dalheimdall

Python versions License: MIT

Python port of the R heimdall package — Drift Adaptable Models.

dalheimdall extends the DAL Experiment Line (pydaltoolbox) to streaming data and non-stationary environments, providing a unified API for concept drift detection, reactive retraining, recurrent concept pools, and controlled drift benchmarking.

Installation

pip install dalheimdall

For local development:

pip install -e ".[dev]"

Quickstart

1. Concept Drift Detection

import dalheimdall as ph

data = ph.datasets.st_drift_examples()
stream = data["multivariate"]

detector = ph.DfrAdwin(target_feat="x1", delta=0.002)
detector.fit(stream)

print("Drift detected:", detector.drifted)
print(detector.drifter_output.tail())

2. Reactive Retraining (AdpRetrain)

import numpy as np
import pandas as pd
import pydaltoolbox as dal
import dalheimdall as ph

rng = np.random.default_rng(42)
x = rng.normal(0, 1, size=(200, 2))
y = (x[:, 0] > 0).astype(int)
y[100:] = (x[100:, 0] <= 0).astype(int)  # abrupt concept flip
df = pd.DataFrame({"x1": x[:, 0], "x2": x[:, 1], "y": y.astype(str)})

workflow = ph.AdpRetrain(
    model=dal.ClaDtree("y", slevels=["0", "1"], random_state=42),
    drift_method=ph.DfrDdm(min_instances=20),
    warmup_size=40,
)
for start in range(0, len(df), 40):
    batch = df.iloc[start : start + 40]
    workflow.fit(batch[["x1", "x2"]], batch[["y"]])

print("Drift detected on last batch:", workflow.drifted)

3. Recurrent Concept Pools (AdpRecurrent)

import pydaltoolbox as dal
import dalheimdall as ph

workflow = ph.recurrent_ensemble(
    method=dal.ClaDtree("y", slevels=["0", "1"], random_state=42),
    train_size=40,
    numerical_cols=["x1", "x2"],
    detector=ph.DfrAdwin(target_feat="x1"),
    memory=ph.MemoryBasic(),
)

What's Included

Every detector inherits from Drifter (ErrorBased, DistBased, or MvDistBased), supporting streaming update_state(value) -> bool, batch fit(data) -> self (populating drifter_output), and reset_state().

Group Classes & Functions
Core & Infrastructure Drifter, Dummy, DfrInactive, DfrPassive, ErrorBased, DistBased, MvDistBased, DfrMultiCriteria, DriftWorkflow, drift_step, OneHot, TransPipeline, NrmBase, NrmMemory, MemoryManager, MemoryBasic, MemoryOversampling, MemoryUndersampling
Metrics Metric, MtAccuracy, MtPrecision, MtRecall, MtFscore, MtRocauc, cm_metrics, f1_aggregate
Error-Based Detectors DfrDdm, DfrEddm, DfrHddm, DfrEcdd, DfrCusum
Univariate Distribution Detectors DfrAdwin, DfrPageHinkley, DfrKswin, DfrLbdd, DfrMcdd, DfrPsi, DfrOnlinebcp, DfrFastlr, DfrGreedyks, DfrIks, DfrQts, psi, online_bcp, fastlr_split, ks_sf, GreedyKS, iks_ca, IKS
Multivariate & Structural Detectors DfrKldist, DfrAedd, DfrCosine, DfrEikmeans, DfrMmqt, DfrDde, DfrLlr2, cosine_score, eikmeans, eikmeans_test, mmqt, mmqt_test, dde_curve, dde_score, dde_feature_drift, spbn, spbn_loglik
Ensemble, OOD & Student-Teacher DfrStudd, DfrProton, DfrEnsemble, ensemble_vote
Neural & Deep CPD Detectors DfrPadd, DfrMcd, DfrIndid, DfrWwAggr, indid, indid_predict, tscp2, ts2vec, cpd_scores, cpd_calibrate, cpd_ensemble, cpd_ensemble_fit, wwaggr
Adaptive Workflows AdpRetrain, AdpRecurrent, adapt_static, adapt_retrain, adapt_incremental, adapt_reset, recurrent_ensemble, recurrent_incremental, Concept, ConceptPool, ConceptPoolInactive, TrainStatic, TrainRetrain, TrainIncremental, SlctInactive, SlctPsi, SlctErrorMetrics, SlctPsiThenBest, SlctPsiThenError, SlctAe, EvtLeastUsed, EvtRedundant, RankRatio, RankPsi, RareKeep, RareDrop, RecAlways, RecStable, LearnedLimit
Benchmarks & Datasets datasets.st_drift_examples(), dsg_source, dsg_take, dsg_drift, dsg_stream, dsg_mmd_test, dsg_source_data, dsg_source_regions, dsg_sea, dsg_sine, dsg_mixed, dsg_agrawal

Examples

Rendered examples live in examples/README.md and are generated from executable Markdown notebooks under notebooks/ via:

python notebooks/conversor.py

License

MIT

Metadata

Release files for dalheimdall 1.0.717

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dalheimdall 1.0.717
File Size Uploaded Provenance Actions
dalheimdall-1.0.717.tar.gz 129.0 kB Without provenance Details for dalheimdall-1.0.717.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dalheimdall 1.0.717
File Interpreter ABI Platform Actions
dalheimdall-1.0.717-py3-none-any.whl Python 3 none any Details for dalheimdall-1.0.717-py3-none-any.whl

Total release size: 274.2 kB

Release files / dalheimdall-1.0.717.tar.gz

Download URL dalheimdall-1.0.717.tar.gz
Size 129.0 kB
Tags Source
SHA-256 checksum
How to use checksums
7e1e3bd4e5134362b45d91e6aad25bd091bf7a123daac5e6be4040056c46baab
BLAKE2b-256 checksum
How to use checksums
baaea4539b855b7311eba7b76b30ed411704ac5954efd9fe14b0a73c98b4be34
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.0

Release files / dalheimdall-1.0.717-py3-none-any.whl

Download URL dalheimdall-1.0.717-py3-none-any.whl
Size 145.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d51482017d29d009b29689288c4bd1254d28e7958fdde9239b0d3fa5d5d3593f
BLAKE2b-256 checksum
How to use checksums
8c00953d40e082ab864c1cc5e8ef0b131f033da8c2671f3492c4e06994a9a8ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.0

Security for dalheimdall 1.0.717

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page