SkillAgentSearch skills...

APDTFlow

APDTFlow is a modern and extensible forecasting framework for time series data that leverages advanced techniques including neural ordinary differential equations (Neural ODEs), transformer-based components, and probabilistic modeling. Its modular design allows researchers and practitioners to experiment with multiple forecasting models and easily

Install / Use

/learn @yotambraun/APDTFlow

README

APDTFlow: Production-Ready Time Series Forecasting with Neural ODEs

<p align="center"> <img src="assets/images/my_logo_framework.png" alt="APDTFlow Logo" width="300"> </p>

PyPI version License: MIT Downloads Python Versions CI Coverage

The only Python package offering continuous-time forecasting with Neural ODEs. Combine cutting-edge research with a simple fit()/predict() API for production-ready forecasting.


🎯 What You Can Do with APDTFlow

Get 95% Confidence Intervals in 5 Lines

from apdtflow import APDTFlowForecaster

model = APDTFlowForecaster(forecast_horizon=7, use_conformal=True)
model.fit(df, target_col='sales', date_col='date')
lower, pred, upper = model.predict(alpha=0.05, return_intervals='conformal')
# Output: Guaranteed 95% coverage - perfect for production risk management

Boost Accuracy 30-50% with External Features

model = APDTFlowForecaster(forecast_horizon=14, exog_fusion_type='gated')
model.fit(df, target_col='sales', exog_cols=['temperature', 'holiday', 'promotion'])
predictions = model.predict(exog_future=future_df)
# Output: Seamlessly incorporate weather, holidays, and promotions for better forecasts

Validate Models with Rolling Window Backtesting

results = model.historical_forecasts(data=df, start=0.8, stride=7)
print(f"MASE: {results['abs_error'].mean():.2f}")
# Output: MASE: 0.85 (beats naive forecast! < 1.0 = good)

Handle Irregular Time Series with Neural ODEs

model = APDTFlowForecaster(model_type='ode')  # Continuous-time modeling
model.fit(irregular_data)  # Works with missing data & irregular intervals
predictions = model.predict()
# Output: Neural ODEs handle gaps and irregular sampling naturally

Use Categorical Features (Day-of-Week, Holidays, Store IDs)

model = APDTFlowForecaster(forecast_horizon=7)
model.fit(
    df,
    target_col='sales',
    categorical_cols=['day_of_week', 'store_id', 'promotion_type']
)
predictions = model.predict()
# Output: Automatic one-hot encoding or embeddings - no manual preprocessing needed

📦 Installation

APDTFlow is published on PyPI:

pip install apdtflow

For development:

git clone https://github.com/yotambraun/APDTFlow.git
cd APDTFlow
pip install -e .

📑 Table of Contents

  1. What You Can Do
  2. Installation
  3. Why APDTFlow?
  4. Key Features
  5. Quick Start
  6. Features & Usage
  7. Model Architectures
  8. Evaluation & Metrics
  9. Experiment Results
  10. Documentation & Examples
  11. Additional Capabilities
  12. License

🔬 Why APDTFlow?

Unique Capabilities

APDTFlow stands out with continuous-time forecasting using Neural ODEs and modern research features:

  • 🔬 Continuous-Time Neural ODEs: Model temporal dynamics with differential equations - better for irregular time series and missing data
  • 📊 Conformal Prediction: Rigorous uncertainty quantification with finite-sample coverage guarantees
  • 🌟 Advanced Exogenous Support: 3 fusion strategies (gated, attention, concat) → 30-50% accuracy boost
  • 📈 Industry-Standard Metrics: MASE, sMAPE, CRPS, Coverage for rigorous evaluation
  • 🔄 Backtesting: Darts-style rolling window validation with historical_forecasts()
  • ⚡ Simple API: Just fit() and predict() with multiple architectures (ODE, Transformer, TCN, Ensemble)

When to Use APDTFlow

  • Financial forecasting - Rigorous uncertainty bounds for risk management
  • Retail demand - Holidays, promotions, seasonal patterns with categorical features
  • Energy consumption - Weather, temperature, and external events as exogenous variables
  • Healthcare demand - Demographic and policy changes with conformal prediction
  • Any scenario requiring continuous-time modeling or sophisticated exogenous variable handling

Comparison with Other Libraries

| Feature | APDTFlow | Darts | NeuralForecast | Prophet | |---------|----------|-------|----------------|---------| | Neural ODEs | ✅ Continuous-time | ❌ No | ❌ No | ❌ No | | Exogenous Variables | ✅ 3 fusion strategies | ✅ Yes | ✅ Yes | ✅ Yes | | Conformal Prediction | ✅ Rigorous uncertainty | ⚠️ Limited | ❌ No | ❌ No | | Backtesting | ✅ historical_forecasts() | ✅ Yes | ⚠️ Limited | ❌ No | | Industry Metrics | ✅ MASE, sMAPE, CRPS | ✅ Yes | ✅ Yes | ⚠️ Limited | | Categorical Features | ✅ One-hot & embeddings | ✅ Yes | ✅ Yes | ⚠️ Limited | | Multi-Scale Decomposition | ✅ Trends + seasonality | ⚠️ Limited | ❌ No | ✅ Yes | | Simple fit()/predict() API | ✅ 5 lines of code | ✅ Yes | ⚠️ Varies | ✅ Yes | | Multiple Architectures | ✅ ODE/Transformer/TCN | ✅ Many | ✅ Many | ❌ One | | PyTorch-based | ✅ GPU acceleration | ⚠️ Mixed | ✅ Yes | ❌ No |


✨ Key Features

📊 Industry-Standard Metrics

Evaluate with metrics used by leading forecasting teams:

from apdtflow import APDTFlowForecaster

model = APDTFlowForecaster(forecast_horizon=14)
model.fit(df, target_col='sales', date_col='date')

# Industry-standard metrics: MASE, sMAPE, CRPS, Coverage
mase = model.score(test_df, target_col='sales', metric='mase')
# Output: 0.85  # < 1.0 = beats naive forecast

smape = model.score(test_df, target_col='sales', metric='smape')
# Output: 12.3  # Symmetric MAPE percentage

Available Metrics:

  • MASE (Mean Absolute Scaled Error) - Scale-independent, M-competition standard
  • sMAPE (Symmetric MAPE) - Better than MAPE, bounded 0-200%
  • CRPS (Continuous Ranked Probability Score) - For probabilistic forecasts
  • Coverage - Prediction interval calibration (e.g., 95% intervals)

🔄 Backtesting / Historical Forecasts

Validate models with Darts-style rolling window backtesting:

# Backtest model on historical data
backtest_results = model.historical_forecasts(
    data=df,
    target_col='sales',
    date_col='date',
    start=0.8,           # Start at 80% of data
    forecast_horizon=7,  # 7-day forecasts
    stride=7,            # Weekly frequency
    retrain=False,       # Fast: use fixed model
    metrics=['MAE', 'MASE', 'sMAPE']
)

# Output: DataFrame with columns:
#   timestamp, fold, forecast_step, actual, predicted, error, abs_error

print(f"Total forecasts: {backtest_results['fold'].nunique()}")
# Output: Total forecasts: 5

print(f"Average MASE: {backtest_results['abs_error'].mean():.3f}")
# Output: Average MASE: 0.923

Features:

  • Rolling window validation - Simulate production forecasting
  • Fixed or retrain modes - Trade speed vs realism
  • Flexible parameters - Control start point, stride, horizon
  • Comprehensive output - Timestamp, actual, predicted, fold, errors

📊 Conformal Prediction

Get calibrated prediction intervals with coverage guarantees:

model = APDTFlowForecaster(
    forecast_horizon=14,
    use_conformal=True,        # Enable conformal prediction
    conformal_method='adaptive' # Adapts to changing data
)

model.fit(df, target_col='sales')

# Get calibrated 95% prediction intervals
lower, pred, upper = model.predict(
    alpha=0.05,  # 95% coverage guarantee
    return_intervals='conformal'
)

# Output:
#   lower: array([98.2, 97.5, ...])   # Lower bounds
#   pred:  array([105.3, 104.1, ...])  # Point predictions
#   upper: array([112.4, 110.7, ...])  # Upper bounds
# Guarantee: 95% of actual values will fall within [lower, upper]

Why Conformal Prediction?

  • Finite-sample guarantees - Not just asymptotic
  • Distribution-free - No assumptions about data distribution
  • Adaptive methods - Adjust to changing patterns
  • Production-ready - Used in finance, healthcare, energy

🌟 Exogenous Variables

Boost accuracy 30-50% with external features:

# Use external features like temperature, holidays, promotions
model = APDTFlowForecaster(
    forecast_horizon=14,
    exog_fusion_type='gated'  # or 'attention', 'concat'
)

model.fit(
    df,
    target_col='sales',
    date_col='date',
    exog_cols=['temperature', 'is_holiday', 'promotion'],
    future_exog_cols=['is_holiday', 'promotion']  # Known in advance
)

# Predict with future exogenous data
future_exog = pd.DataFrame({
    'is_holiday': [0, 1, 0, 0, ...],
    'promotion': [1, 0, 1, 0, ...]
})
predictions = model.predict(exog_future=future_exog)
# Output: array([135.2, 145.8, 132.1, ...])  # Improved accuracy with external features

Fusion Strategies:

  • Gated - Learn importance weights for each feature
  • Attention - Dynamic feature weighting based on context
  • Concat - Simple concatenation (baseline)

Impact: Research shows 30-50% accuracy improvement in retail, energy, and demand forecasting.


⚡ Simple API

Production-ready forecasting in 5 lines:

from apdtflow

Related Skills

View on GitHub
GitHub Stars43
CategoryData
Updated26d ago
Forks5

Languages

Python

Security Score

95/100

Audited on Mar 2, 2026

No findings