Skip to main content

TimeSmith for ML models

Project description

TimeSmith

PyPI version Python 3.9+ License: MIT Tests Documentation Code style: black

TimeSmith is a time series machine learning library with strict layer boundaries and a clean architecture.

Architecture

TimeSmith uses a four-layer architecture with strict boundaries:

Layer 1: Typing (timesmith/typing)

Scientific types and runtime validators for time series data structures:

  • SeriesLike: pandas Series or single-column DataFrame with datetime/int index
  • PanelLike: DataFrame with entity key plus time index
  • TableLike: DataFrame with row index aligned to time
  • ForecastLike: Forecast results with predictions and optional intervals

Layer 2: Core (timesmith/core)

Base classes, parameter handling, tags, and input validation:

  • BaseObject: Parameter management (get_params, set_params, clone)
  • BaseEstimator: Base class with fit capability
  • BaseTransformer: Transformers with transform and optional inverse_transform
  • BaseForecaster: Forecasters with predict and optional predict_interval
  • BaseDetector: Anomaly detectors with score and predict
  • BaseFeaturizer: Transformers that output TableLike data

Layer 3: Compose (timesmith/compose)

Pipeline and adapter objects for composition:

  • Pipeline: Chains transformer steps with scitype change support
  • ForecasterPipeline: Transformer(s) then forecaster
  • Adapter: Converts between scitypes (Series ↔ Table)
  • FeatureUnion: Runs multiple featurizers and concatenates results

Layer 4: Tasks & Eval (timesmith/tasks, timesmith/eval)

Task objects and evaluation tools:

  • ForecastTask: Binds data, horizon, and target semantics
  • DetectTask: Anomaly detection task definition
  • ExpandingWindowSplit, SlidingWindowSplit: Cross-validation splitters
  • backtest_forecaster: Run backtests with metrics
  • summarize_backtest: Aggregate and per-fold metrics

Quick Example

import pandas as pd
from timesmith import ForecastTask, backtest_forecaster, make_forecaster_pipeline
from timesmith.examples import NaiveForecaster, LogTransformer

# Load data
y = pd.Series([...], index=pd.date_range("2020-01-01", periods=100))

# Create forecast task
task = ForecastTask(y=y, fh=5, frequency="D")

# Build pipeline
transformer = LogTransformer(offset=1.0)
forecaster = NaiveForecaster()
pipeline = make_forecaster_pipeline(transformer, forecaster=forecaster)

# Run backtest
result = backtest_forecaster(pipeline, task)

# Summarize results
summary = summarize_backtest(result)
print(f"Mean MAE: {summary['aggregate_metrics']['mean_mae']:.4f}")

Running the Example

python examples/basic_forecast.py

This will:

  1. Load/generate example data
  2. Create a forecast task
  3. Build a pipeline with transformer and forecaster
  4. Run backtest
  5. Print summary metrics

Installation

pip install timesmith

Development

# Install in development mode
pip install -e ".[dev]"

# Run tests
pytest tests/

# Format code
black timesmith tests

# Run linting
flake8 timesmith tests

Design Principles

  1. Strict Layer Boundaries: Core cannot import eval. Typing cannot import anything.
  2. Validation at Boundaries: Validate once at public API boundaries only.
  3. Task Semantics: Tasks hold semantics. Estimators only store params and fitted state.
  4. Composition: Use pipelines and adapters for flexible workflows.
  5. Type Safety: Scientific types with runtime validators for data structures.

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

timesmith-0.0.1.tar.gz (70.4 kB view details)

Uploaded Source

Built Distribution

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

timesmith-0.0.1-py3-none-any.whl (99.2 kB view details)

Uploaded Python 3

File details

Details for the file timesmith-0.0.1.tar.gz.

File metadata

  • Download URL: timesmith-0.0.1.tar.gz
  • Upload date:
  • Size: 70.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for timesmith-0.0.1.tar.gz
Algorithm Hash digest
SHA256 75b6f7c850b5dc8aba62a4f621ddd796cc4cb0ca866ce3200918021ac0124bce
MD5 810cbf89fba2a6cd5d7960f2a28e4533
BLAKE2b-256 0401a454c72ad13a40a59ddf197ba53dd0e9b24669d1034c574dd264d8e54a01

See more details on using hashes here.

Provenance

The following attestation bundles were made for timesmith-0.0.1.tar.gz:

Publisher: release.yml on kylejones200/timesmith

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file timesmith-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: timesmith-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 99.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for timesmith-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 df5ffaf9ca81d44e84e9c143be08133ae49b87503dd982f9c43ca91425f1654d
MD5 fcebd515915fa45e7164a27013d35a20
BLAKE2b-256 cd473ed51f86bcf62817d0d197a3ee43381ab413b57e8f373a495a7314d1bf5a

See more details on using hashes here.

Provenance

The following attestation bundles were made for timesmith-0.0.1-py3-none-any.whl:

Publisher: release.yml on kylejones200/timesmith

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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