60-second start

Quickstart

One install, one trained model, three kinds of questions. Continuous-time forecasting with calibrated uncertainty on both value and time.

$ pip install apdtflow

The whole API at a glance

Two flags unlock the timing capabilities: decoder_type='continuous' swaps in the Neural-ODE decoder you can query at any real-valued time, and use_conformal=True calibrates the uncertainty windows.

python
from apdtflow import APDTFlowForecaster

model = APDTFlowForecaster(forecast_horizon=40, decoder_type='continuous',
                           use_conformal=True)
model.fit(df, target_col='capacity', feature_cols=sensor_cols)

model.predict()                                       # classic grid forecast
model.predict_at(['2026-06-14 14:37', 3.6])           # value at ANY moment
result = model.predict_when(threshold=1.4,            # WHEN it crosses the line
                            direction='below')
result.eta, result.act_by, result.censored
schedule = model.predict_when_fleet(assets,           # whole fleet -> ranked schedule
                                    threshold=1.4, direction='below')

Run it now

Real data, about a minute and a half on a laptop CPU. censored=True is a valid answer ("no crossing within the horizon at this confidence"), and a common one here. device='auto' (the default) uses a CUDA GPU or Apple MPS when present; when a GPU actually helps.

python
import pandas as pd
from apdtflow import APDTFlowForecaster

url = ("https://raw.githubusercontent.com/yotambraun/APDTFlow/main/"
       "dataset_examples/daily-minimum-temperatures-in-me_clean.csv")
df = pd.read_csv(url, parse_dates=["Date"])

model = APDTFlowForecaster(forecast_horizon=14, history_length=30, num_epochs=5,
                           decoder_type="continuous", use_conformal=True)
model.fit(df, target_col="Daily minimum temperatures", date_col="Date")

print(model.predict())                          # next 14 days
print(model.predict_at(["1991-01-01 14:37", 3.6]))  # any moment: timestamp or step offset
r = model.predict_when(threshold=11.0, direction="below", alpha=0.1)  # below 11 °C?
print(r.eta, r.earliest, r.latest, r.act_by, r.censored)  # schedule by act_by
predict()

Next k values on the grid, with optional conformal intervals.

predict_at(times)

Value at arbitrary timestamps — fractional steps, beyond the horizon.

predict_when(threshold)

A calibrated 90% window on the crossing time, plus an act_by edge.

Prefer a runnable notebook?

The Quickstart notebook covers all three questions end-to-end and opens in Colab with zero setup.