TimeSmith for ML models
Project description
TimeSmith
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 indexPanelLike: DataFrame with entity key plus time indexTableLike: DataFrame with row index aligned to timeForecastLike: 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 withfitcapabilityBaseTransformer: Transformers withtransformand optionalinverse_transformBaseForecaster: Forecasters withpredictand optionalpredict_intervalBaseDetector: Anomaly detectors withscoreandpredictBaseFeaturizer: Transformers that outputTableLikedata
Layer 3: Compose (timesmith/compose)
Pipeline and adapter objects for composition:
Pipeline: Chains transformer steps with scitype change supportForecasterPipeline: Transformer(s) then forecasterAdapter: 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 semanticsDetectTask: Anomaly detection task definitionExpandingWindowSplit,SlidingWindowSplit: Cross-validation splittersbacktest_forecaster: Run backtests with metricssummarize_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:
- Load/generate example data
- Create a forecast task
- Build a pipeline with transformer and forecaster
- Run backtest
- 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
- Strict Layer Boundaries: Core cannot import eval. Typing cannot import anything.
- Validation at Boundaries: Validate once at public API boundaries only.
- Task Semantics: Tasks hold semantics. Estimators only store params and fitted state.
- Composition: Use pipelines and adapters for flexible workflows.
- 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file timesmith-0.1.0.tar.gz.
File metadata
- Download URL: timesmith-0.1.0.tar.gz
- Upload date:
- Size: 96.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e753a1c2b68321e97d10f340d41502ab9c0c47bca942b8a7e4c7e8aaef500c34
|
|
| MD5 |
f16e54198b741562e03c5b1d554e0f84
|
|
| BLAKE2b-256 |
71da1088f7051875444071a387c550e9593cc24f4ade1e543fec0ba6828cd6eb
|
Provenance
The following attestation bundles were made for timesmith-0.1.0.tar.gz:
Publisher:
release.yml on kylejones200/timesmith
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
timesmith-0.1.0.tar.gz -
Subject digest:
e753a1c2b68321e97d10f340d41502ab9c0c47bca942b8a7e4c7e8aaef500c34 - Sigstore transparency entry: 810413411
- Sigstore integration time:
-
Permalink:
kylejones200/timesmith@6e53e8f49b756f4f68cbe678c08662a8e95285c3 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/kylejones200
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6e53e8f49b756f4f68cbe678c08662a8e95285c3 -
Trigger Event:
push
-
Statement type:
File details
Details for the file timesmith-0.1.0-py3-none-any.whl.
File metadata
- Download URL: timesmith-0.1.0-py3-none-any.whl
- Upload date:
- Size: 133.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
859f7dae3b4bdad245d789629bbee0d5e58f744bb5af2bfcd46cfda42bd82d73
|
|
| MD5 |
8fb7bc54d692467ae8ac05e95c72ca3c
|
|
| BLAKE2b-256 |
2c64edadd207efd1ccab9f88a4bc9c0f18cdf09a4dc321e2fefe38180741e34b
|
Provenance
The following attestation bundles were made for timesmith-0.1.0-py3-none-any.whl:
Publisher:
release.yml on kylejones200/timesmith
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
timesmith-0.1.0-py3-none-any.whl -
Subject digest:
859f7dae3b4bdad245d789629bbee0d5e58f744bb5af2bfcd46cfda42bd82d73 - Sigstore transparency entry: 810413466
- Sigstore integration time:
-
Permalink:
kylejones200/timesmith@6e53e8f49b756f4f68cbe678c08662a8e95285c3 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/kylejones200
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6e53e8f49b756f4f68cbe678c08662a8e95285c3 -
Trigger Event:
push
-
Statement type: