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
Features
- Model Serialization: Save and load fitted models
- Comprehensive Error Handling: Custom exceptions with context
- Logging Configuration: Centralized logging with environment variable support
- Data Validation: Edge case handling and data quality checks
- Pipeline Composition: Flexible transformer and forecaster pipelines
- Backtesting: Time series cross-validation with multiple metrics
- Network Analysis: Graph-based time series analysis
- Multiple Forecasters: ARIMA, Prophet, LSTM, Bayesian, and more
Model Serialization
from timesmith import SimpleMovingAverageForecaster, save_model, load_model
# Fit and save
forecaster = SimpleMovingAverageForecaster(window=5)
forecaster.fit(y)
save_model(forecaster, "model.pkl")
# Load later
loaded = load_model("model.pkl")
forecast = loaded.predict(fh=10)
Error Handling
TimeSmith provides custom exceptions for better error handling:
from timesmith import NotFittedError, DataError, ValidationError
try:
forecaster.predict(fh=5)
except NotFittedError as e:
print(f"Error: {e}")
print(f"Context: {e.context}")
Logging
Configure logging via environment variables:
export TIMESMITH_LOG_LEVEL=DEBUG
export TIMESMITH_LOG_FORMAT=detailed
Or programmatically:
from timesmith.logging_config import configure_logging
configure_logging(level="INFO")
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.
Requirements
Core dependencies (minimal):
- Python 3.12 or higher
- pandas >= 1.5.0
- numpy >= 1.20.0
Optional dependencies:
scipy- For filters, changepoint detection, distances (install:pip install timesmith[scipy])networkx- For network analysis features (install:pip install timesmith[network])- See
pyproject.tomlfor all optional dependency groups - networkx >= 3.0
See pyproject.toml for optional dependencies for specific forecasters.
Metadata
Release files for timesmith 0.1.2
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 |
|---|---|---|---|---|
| timesmith-0.1.2.tar.gz | 121.0 kB | With provenance | Details for timesmith-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| timesmith-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for timesmith-0.1.2-py3-none-any.whl |
Total release size: 289.0 kB
Release files / timesmith-0.1.2.tar.gz
| Download URL | timesmith-0.1.2.tar.gz |
|---|---|
| Size | 121.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a1719a93bf1b39a7a0a0884868396c0d044ead3603303dd5de18117629dbee17
|
|
BLAKE2b-256 checksum How to use checksums |
ce0a7dc97e9f12946514a7514cc1efefb6fe8dc552181acbfcb241e9d3438fd0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 12, 2026.
Transparency logRelease files / timesmith-0.1.2-py3-none-any.whl
| Download URL | timesmith-0.1.2-py3-none-any.whl |
|---|---|
| Size | 168.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
acb79bb7d231459cbc71009ff631a9c8c7e42ea8e541ff78470ce981c284cc09
|
|
BLAKE2b-256 checksum How to use checksums |
5e06835282008384c6748d16eab4d2074aa18a20e4d6d254190c7855893725e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 12, 2026.
Transparency logSecurity for timesmith 0.1.2
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for timesmith-0.1.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 12, 2026.
Transparency logA 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.