Skip to main content

timeframes logo

A lightweight framework for time series validation, backtesting, and visualization.
Timeframes provides simple and efficient tools for splitting, validating, and evaluating forecasting models — without unnecessary dependencies or boilerplate.


🧠 Need help?

Try TimeframesGPT —
a specialized assistant trained on the full Timeframes codices.


Installation

pip install timeframes

Quick Example

import timeframes as ts
from sklearn.linear_model import LinearRegression

# Load example data
df = ts.load_example("air_passengers")  # or "ts_components", "ts_components_complex"

# Split into train, validation, and test
train, val, test = ts.split(df, ratios=(0.7, 0.2, 0.1))

# Validate using walk-forward cross-validation
model = LinearRegression()
report, (y_true, y_pred) = ts.validate(
    model, df, target_col="AirPassengers", method="walkforward", mode="expanding", folds=5, return_preds=True
)

print(report)
# {'mae': 0.213, 'rmse': 0.322, 'smape': 3.9}

# Visualize forecast results
ts.plot_forecast(y_true, y_pred, title="Walk-Forward Forecast", show_residuals=True)
example

💡 You can list all built-in datasets with ts.list_examples().


✨ Features

  • Minimal — depends only on NumPy and pandas.
  • Consistent — unified API for all validation methods.
  • Flexible — works with any model exposing .fit() / .predict().
  • Visual — built-in plot_forecast() with datetime alignment and residuals.
  • Transparent — every function returns clear, reproducible outputs.

🧩 Supported Methods

Function Description
ts.split() Single train/validation/test split
ts.validate() Cross-validation (walk-forward or temporal K-Fold)
ts.backtest() Out-of-sample testing
ts.evaluate() Metric evaluation (MAE, RMSE, sMAPE, rMAE)

📂 Examples

Timeframes includes several runnable demonstrations for validation, backtesting, and visualization:

Script Description
examples/forecasts.py Full workflow: validation + backtest + plots
examples/kfold_demo.py Temporal K-Fold cross-validation
examples/visualize_splits_demo.py Visualize expanding, moving, and K-Fold splits

Run any example directly:

python examples/forecasts.py

Or run all __main__ demos automatically (via pytest):

pytest

This executes every example and internal demonstration, ensuring reproducibility across releases.


🧠 Built-in Datasets

Name Description Period Source
air_passengers Classic airline passenger dataset 1949–1960 Public domain (Box & Jenkins, 1976)
ts_components Synthetic trend + seasonality decomposition 2000–2011 Generated (Andrew R. Garcia, 2025)
ts_components_complex Nonlinear trend + multi-frequency seasonality 2000–2011 Generated (Andrew R. Garcia, 2025)

Load with:

df = ts.load_example("ts_components")

List all available datasets:

ts.list_examples()

📈 Visualization Example

ts.plot_forecast(
    y_true, 
    y_pred, 
    title="Out-of-Sample Forecast", 
    show_residuals=True
)

Generates a clean, publication-ready figure with automatic datetime indexing and optional residual bars.


License

MIT License © 2025 Andrew R. Garcia

Metadata

Release files for timeframes 1.3.0

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

Source distribution (sdist)

Source distribution for timeframes 1.3.0
File Size Uploaded
timeframes-1.3.0.tar.gz 22.0 kB Details

Built distribution (wheel)

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

Total release size: 44.6 kB

Release files / timeframes-1.3.0.tar.gz

Download URL timeframes-1.3.0.tar.gz
Size 22.0 kB
Tags Source
SHA-256 checksum
How to use checksums
7c38db8943092ebe90ae80d4846a2c5a384bf0d03a0479df8ae09684a3746de8
BLAKE2b-256 checksum
How to use checksums
3135208900e327d1575c25c2d86c4b0bd1bd491da32bdd693fd3deede6134b85
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / timeframes-1.3.0-py3-none-any.whl

Download URL timeframes-1.3.0-py3-none-any.whl
Size 22.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ebbe866a913fcc450019d2929dd89db4518db15e1733f35abeb2437fc1c32157
BLAKE2b-256 checksum
How to use checksums
f2f458cf39366c19dda3531bc4bbeb9d8d8764c55bc6195e56d7846912f62616
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

1.3.0 This release

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

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