Modular Time Series Forecasting Library
Project description
foreBlocks
foreBlocks is a modular PyTorch toolkit for time-series forecasting, experiment management, and companion utilities.
This repository is structured as two cooperating packages:
foreblocks: forecasting models, training, evaluation, preprocessing, DARTS search, and conformal uncertainty.foretools: companion utilities for synthetic data, feature engineering, decomposition, and hyperparameter search.
The recommended workflow is:
- start with the stable top-level public API in
foreblocks - validate one small training loop end to end
- add preprocessing, search, or specialist tooling only when the baseline path works
Install
This package requires Python 3.10 or newer.
Core install
pip install foreblocks
Optional extras
| Extra | Adds |
|---|---|
preprocessing |
TimeSeriesHandler, windowing, scaling, filtering, imputation, and time-feature generation |
darts |
DARTS architecture search, evaluation, and NAS dependencies |
mltracker |
experiment tracking API, local dashboard, and CLI TUI |
studio |
Studio frontend launcher and bundled server command |
vmd |
VMD decomposition, search support, and analysis helpers |
wavelets |
wavelet preprocessing and attention-head utilities |
benchmark |
external forecasting baselines and spreadsheet readers |
foreminer |
changepoint detection, dataset mining, and analysis utilities |
all |
all runtime extras above |
Examples:
pip install "foreblocks[darts]"
pip install "foreblocks[mltracker]"
pip install "foreblocks[studio]"
pip install "foreblocks[vmd,wavelets]"
pip install "foreblocks[all]"
Local development install
git clone https://github.com/lseman/foreblocks.git
cd foreblocks
pip install -e ".[dev]"
Launch the Studio frontend
foreblocks-studio
By default, this opens a browser on 127.0.0.1 or localhost.
Optional flags:
foreblocks-studio --open
foreblocks-studio --no-open
foreblocks-studio --host 0.0.0.0 --port 8080
Quickstart
The smallest reliable path is a direct forecasting model with a custom head. This path avoids extra dependencies and verifies that the public API is wired correctly.
import numpy as np
import torch
import torch.nn as nn
from foreblocks import (
ForecastingModel,
ModelEvaluator,
Trainer,
TrainingConfig,
create_dataloaders,
)
seq_len = 24
horizon = 6
n_features = 4
rng = np.random.default_rng(0)
X_train = rng.normal(size=(64, seq_len, n_features)).astype("float32")
y_train = rng.normal(size=(64, horizon)).astype("float32")
X_val = rng.normal(size=(16, seq_len, n_features)).astype("float32")
y_val = rng.normal(size=(16, horizon)).astype("float32")
train_loader, val_loader = create_dataloaders(
X_train,
y_train,
X_val,
y_val,
batch_size=16,
)
head = nn.Sequential(
nn.Flatten(),
nn.Linear(seq_len * n_features, 64),
nn.GELU(),
nn.Linear(64, horizon),
)
model = ForecastingModel(
head=head,
forecasting_strategy="direct",
model_type="head_only",
target_len=horizon,
)
trainer = Trainer(
model,
config=TrainingConfig(
num_epochs=5,
batch_size=16,
patience=3,
use_amp=False,
),
auto_track=False,
)
history = trainer.train(train_loader, val_loader)
evaluator = ModelEvaluator(trainer)
metrics = evaluator.compute_metrics(torch.tensor(X_val), torch.tensor(y_val))
print(history.train_losses[-1], metrics)
Why this path
- validates that the import surface works
- checks dataloader shapes and model output sizes
- avoids optional subsystems during the first run
- keeps the first success criterion small and confirmable
If you start from a raw [T, D] time series instead of windows, use TimeSeriesHandler from foreblocks.ts_handler after installing foreblocks[preprocessing].
Public API
The most stable first imports are exposed from the top-level foreblocks package:
| Import | Purpose |
|---|---|
ForecastingModel |
Core forecasting wrapper for direct, autoregressive, and seq2seq-style models |
Trainer |
Training loop with NAS hooks, MLTracker integration, and optional conformal support |
ModelEvaluator |
Prediction helpers, metrics, cross-validation, and training-curve plots |
TimeSeriesHandler |
Raw-series preprocessing, windowing, scaling, and imputation bridge |
TimeSeriesDataset |
Dataset wrapper used by the dataloader helper |
create_dataloaders |
Build train/validation PyTorch dataloaders from NumPy arrays |
ModelConfig, TrainingConfig |
Lightweight configuration dataclasses |
LSTMEncoder, LSTMDecoder, GRUEncoder, GRUDecoder |
Recurrent encoder/decoder blocks |
TransformerEncoder, TransformerDecoder |
Transformer backbones and related advanced features |
AttentionLayer |
Attention module entry point |
Repository map
| Path | What it contains |
|---|---|
foreblocks/core |
ForecastingModel, heads, conformal utilities, sampling |
foreblocks/training |
Trainer, training loop, quantization utilities |
foreblocks/evaluation |
ModelEvaluator, benchmarking helpers |
foreblocks/ts_handler |
TimeSeriesHandler, imputation, filtering, outlier handling |
foreblocks/tf |
transformer stack, attention variants, MoE, norms, embeddings |
foreblocks/darts |
neural architecture search pipeline and evaluation |
foreblocks/mltracker |
experiment tracking server, logging, and TUI integration |
foretools |
synthetic time series, BOHB search, feature engineering, decomposition |
examples/ |
runnable demos and notebooks |
web/ |
static landing page assets for the published site root |
docs/ |
VitePress source for the documentation site |
Documentation map
Start here if you are new to the repository:
Topic guides:
Companion tooling:
Examples and notebooks:
examples/adaptive_mrmr_demo.pyforetools/tsgen/ts_gen_complete_series.ipynbforetools/tsgen/ts_gen_doc.ipynbexamples/
There is a repository-local docs navigation file at docs/.vitepress/config.js.
Current project status
- The repository is broad and still evolving. Some subsystems are more mature than others.
- The top-level imports listed above are the safest place to start.
Trainersupports MLTracker and conformal prediction; useauto_track=Falseduring local smoke tests.- Decoder-based seq2seq and transformer workflows have stricter dimension contracts than the direct forecasting path.
TrainingConfignow centralizes trainer, NAS, MLTracker, and conformal settings.
Contributing
Documentation improvements are especially valuable here because foreblocks spans forecasting models, search, preprocessing, and auxiliary tooling. If you add or change a public API, update:
- this
README.md - the relevant guide under
docs/ - at least one runnable example or notebook
Project details
Release history Release notifications | RSS feed
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 foreblocks-0.1.19.tar.gz.
File metadata
- Download URL: foreblocks-0.1.19.tar.gz
- Upload date:
- Size: 1.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dceb78fa2c9a53c9f3ee3766f357eefb6403a50aa2295ef6c83be8214f8e4c4d
|
|
| MD5 |
176e61d151f5102ff4266f5d248b9cc2
|
|
| BLAKE2b-256 |
0739f9d7eba3f4d9076d335d6ea32663a834253e6726bbaadbf7ca5d67eeb7b3
|
File details
Details for the file foreblocks-0.1.19-py3-none-any.whl.
File metadata
- Download URL: foreblocks-0.1.19-py3-none-any.whl
- Upload date:
- Size: 1.3 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d7aac93f282fcdd68304abbdb30a195209cfbd0f44609be1fd76ae8219eb390
|
|
| MD5 |
ad01cf38c2131314a29237a4192495c0
|
|
| BLAKE2b-256 |
86a90331f494bb84a46c9c16929ae7ef373b7089cd3dbb531aec807cb0b8b1d0
|