Skip to main content

Entity-based time-series processing framework for Python

Project description

TimeSeriesFlow

CI Python 3.10+ License: MIT Release

Entity-based time-series processing for Python, plus AdaptiveForecast for profile-driven model architecture selection.

Write one function per entity (sensor_id, device_id, customer_id, ...). The framework handles grouping, retries, checkpointing, progress, memory tracking, and logging.

Package Role
timeseriesflow Per-entity processing, EntityRunner, CLI (tsflow), checkpoints
adaptiveforecast Series profiling and forecasting architecture recommendations

What is AdaptiveForecast?

AdaptiveForecast answers one question before you train anything:

Given this time series, which forecasting approach is worth trying first?

It profiles volatility, trend, seasonality, gaps, spikes, and data quality, then returns ranked recommendations (moving_average, exponential_smoothing, lstm, ...). Rules are deterministic, not LLM-based.

Situation How it helps
Many sensors or devices Pick a model family per entity, not one global default
Mixed data quality ValidationGate flags series too short or noisy to forecast
Team handoffs reason fields explain each recommendation
With TimeSeriesFlow Profile inside @entity_flow (combined workflow)

It does not train models or produce forecasts. It recommends architecture recipes only.

Install

v0.2.0 from PyPI:

pip install timeseriesflow

Pin a release or install from git:

pip install timeseriesflow==0.2.0
pip install git+https://github.com/baban9/timeseriesflow.git@v0.2.0

Development install:

git clone https://github.com/baban9/timeseriesflow.git
cd timeseriesflow
pip install -e ".[dev]"

Requires Python 3.10+.

Quick start

Recommended API: @entity_flow for logic, EntityRunner or tsflow run for production.

import pandas as pd
from timeseriesflow import EntityContext, entity_flow

df = pd.DataFrame(
    {
        "sensor_id": ["S1", "S1", "S1", "S2", "S2", "S2"],
        "timestamp": pd.date_range("2024-01-01", periods=6, freq="h", tz="UTC"),
        "value": [1.0, 2.0, 3.0, 10.0, 11.0, 12.0],
    }
)

@entity_flow(entity_key="sensor_id", time_key="timestamp")
def process_sensor(df: pd.DataFrame, ctx: EntityContext) -> dict[str, object]:
    return {
        "sensor_id": ctx.entity_id,
        "rows": len(df),
        "mean_value": float(df["value"].mean()),
    }

result = process_sensor.run(df)
print(f"succeeded={result.succeeded} failed={result.failed}")
print(result.outputs)

Expected output:

succeeded=2 failed=0
[{'sensor_id': 'S1', 'rows': 3, 'mean_value': 2.0}, {'sensor_id': 'S2', 'rows': 3, 'mean_value': 11.0}]

CLI

tsflow run examples/basic_pipeline.py
tsflow validate examples/basic_pipeline.py
tsflow info
tsflow checkpoint-status --checkpoint-dir ./checkpoints

AdaptiveForecast

from adaptiveforecast import ProfileAwareArchitectureSelection

result = ProfileAwareArchitectureSelection(
    time_column="timestamp",
    value_column="value",
    max_models=3,
).select(df)

print(result.best_model)
print(result.recommendation.to_dict())

Examples

python examples/advise_and_process.py          # TimeSeriesFlow + AdaptiveForecast
python examples/adaptiveforecast_profile.py  # profiling only
python examples/architecture_selection.py    # full selection workflow

Legacy API: Flow + FlowConfig still works. New projects should use @entity_flow. Deprecation warning planned for v0.2.

Features

TimeSeriesFlow: entity grouping, retries, JSONL checkpoints, Rich progress, memory tracking, CSVSource / ParquetSource, tsflow CLI.

AdaptiveForecast: series profiling, validation gate, seven recipes (naive through cnn_lstm), explainable ModelAdvisor rules.

Documentation

Topic Link
Golden path (recommended) docs/golden_path.md
Combined TS + AdaptiveForecast docs/combined_workflow.md
AdaptiveForecast intro docs/adaptiveforecast.md
Sparse time series docs/sparse_series.md
Architecture selection docs/architecture_selection.md
Getting started docs/getting_started.md
EntityRunner docs/runner.md
CLI docs/cli.md
Public API docs/api.md
Changelog CHANGELOG.md
Publishing releases docs/publishing.md

Development

pytest
ruff check src tests examples
mypy src

Contributing

main is protected. Open a pull request with review; do not push directly to main.

git checkout -b feat/my-change
git push -u origin feat/my-change
gh pr create --fill

See CONTRIBUTING.md and branch protection guide.

License

MIT. See LICENSE.

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

timeseriesflow-0.2.1.tar.gz (38.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

timeseriesflow-0.2.1-py3-none-any.whl (63.1 kB view details)

Uploaded Python 3

File details

Details for the file timeseriesflow-0.2.1.tar.gz.

File metadata

  • Download URL: timeseriesflow-0.2.1.tar.gz
  • Upload date:
  • Size: 38.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.12

File hashes

Hashes for timeseriesflow-0.2.1.tar.gz
Algorithm Hash digest
SHA256 95febaefb2412a36f8b95f7895404348a77c4d6f541e19196b827adec6f5903f
MD5 dd4598aa7e8cdb211de2604ee2f25257
BLAKE2b-256 6a07496299b2319df6634993439eca456326da3239e4817cef37a77ddee6a7c5

See more details on using hashes here.

File details

Details for the file timeseriesflow-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: timeseriesflow-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 63.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.12

File hashes

Hashes for timeseriesflow-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 22756bc71b2420b2f135308e9486fd92367610520931cebb773de12541b177a4
MD5 cac46a346b6e8a4e4b2dc6d96e1a2b46
BLAKE2b-256 ee2c7caa7825acab0b1ee5e795791e7247bea65c776867d14cfa827fd5eba036

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page