Training Time Series Prediction Models (Prophet, NeuralProphet, TimesFM)
Prophet, NeuralProphet and TimesFM — three generations of time series forecasting tools with different tradeoffs between simplicity, flexibility and accuracy. Correct choice depends on data, horizon and interpretability requirements.
Prophet: Decomposition Model
Meta Prophet (2017) — additive model:
y(t) = trend(t) + seasonality(t) + holidays(t) + ε(t)
Trend: piecewise-linear or logistic growth. Changepoints — automatic trend break detection via L1 regularization.
Seasonality: Fourier Series:
- Annual: N=10 (default)
- Weekly: N=3
- Custom: any period
Training and Tuning:
from prophet import Prophet
import pandas as pd
m = Prophet(
changepoint_prior_scale=0.05, # trend flexibility
seasonality_prior_scale=10.0, # seasonality flexibility
holidays_prior_scale=10.0,
seasonality_mode='multiplicative' # for growing data
)
m.add_country_holidays(country_name='US')
m.add_seasonality(name='monthly', period=30.5, fourier_order=5)
m.fit(df) # df with columns ds, y
Tuning Parameters:
-
changepoint_prior_scale: 0.001-0.5, controls trend overfitting -
seasonality_mode: 'additive' for stationary, 'multiplicative' for growing series -
fourier_order: higher = more flexible seasonality = overfit risk
Prophet Cross-Validation:
from prophet.diagnostics import cross_validation, performance_metrics
df_cv = cross_validation(m, initial='730 days', period='180 days', horizon='365 days')
df_p = performance_metrics(df_cv)
NeuralProphet
NeuralProphet (2021) = Prophet + neural network components:
- Autoregressive component (AR-Net): captures nonlinear lag dependencies
- Lagged regressors: nonlinear impact of external factors
- PyTorch training, much faster than MCMC-Prophet
from neuralprophet import NeuralProphet
m = NeuralProphet(
n_forecasts=7, # forecast horizon
n_lags=14, # AR lags
seasonality_mode='auto',
learning_rate=0.01
)
m = m.add_country_holidays('US')
metrics = m.fit(df, freq='D', validation_df=df_val)
When NeuralProphet Beats Prophet:
- Nonlinear lag dependencies exist
- Need multiple-step ahead forecasts with specific steps
- Lagged external regressors available (delayed weather, competitor sales)
TimesFM: Foundation Model from Google
TimesFM (2024) — pretrained foundation model for zero-shot forecasting:
import timesfm
tfm = timesfm.TimesFm(
context_len=512,
horizon_len=128,
input_patch_len=32,
output_patch_len=128,
num_layers=20,
model_dims=1280,
backend='gpu'
)
tfm.load_from_checkpoint(repo_id="google/timesfm-1.0-200m")
# Zero-shot inference
forecast_input = [np.array(historical_data)]
frequency_input = [0] # 0=high freq, 1=low freq
point_forecast, experimental_quantile_forecast = tfm.forecast(
forecast_input, freq=frequency_input
)
TimesFM Advantages:
- Zero-shot: requires no training on your data
- Fast start: first forecast in minutes
- Strong results on most business tasks out of the box
Limitations:
- Doesn't account for known future covariates (holidays, promos) without fine-tuning
- Limited interpretability
- Requires significant context (> 500 points optimal)
Comparative Selection
| Criterion | Prophet | NeuralProphet | TimesFM |
|---|---|---|---|
| Need Interpretability | ✓✓ | ✓ | ✗ |
| Known Future Events | ✓✓ | ✓✓ | ✗ |
| Limited Data (< 2 yrs) | ✓ | ✓ | ✓✓ |
| Nonlinear Lags Important | ✗ | ✓✓ | ✓ |
| Need High Accuracy | ✗ | ✓ | ✓✓ |
| Many Series (>1000) | ✗ | ✓ | ✓✓ |
Training and Validation Practice
Training Pipeline (Prophet Example):
- Data prep: resample to target frequency, handle missing (interpolation / forward fill)
- Analysis: ACF/PACF, decompose, holiday analysis
- Baseline: Seasonal Naive (forecast = value from year ago)
- Prophet fit with default params, cross-validation
- Hyperparameter search: Optuna / grid search on 4-6 params
- Ensemble with competitor (ETS or NeuralProphet)
- Productionization: Airflow DAG, MLflow tracking, API endpoint
Comparison Metrics: SMAPE, MASE (Mean Absolute Scaled Error — normalized by Seasonal Naive), Winkler Score for interval forecasts.
Timeline: tuning and training Prophet/NeuralProphet for single series with cross-validation — 1-2 weeks. Production pipeline with monitoring and auto-retraining — 4-6 weeks.







