Skip to main content
This tutorial evaluates the conformal prediction transfer methods available in mlforecast. We train a model on one domain (M4 Monthly Macro series) and then generate calibrated prediction intervals for a different domain (M4 Monthly Finance series) — without retraining the model.

Why transfer?

Standard conformal prediction intervals are calibrated on the same distribution as training data. When you apply a pretrained model to new, unseen series from a potentially different domain, the source conformity scores may be miscalibrated for the target domain. Transfer conformal methods attempt to correct for this shift using different strategies: We evaluate each method’s empirical coverage — the fraction of test observations that fall inside the predicted interval — and compare it to the nominal level.

Setup

Load M4 Monthly Data

The M4 Monthly dataset contains 48,000 monthly time series across 6 categories. We use it to create a cross-domain transfer scenario:
  • Source domain: Macro category — macroeconomic time series
  • Target domain: Finance category — financial time series
The forecast horizon for M4 Monthly is h = 18 months.

Create Source and Target Domains

Explore the Domains

Let’s visualize a few series from each domain to get a sense of the distribution shift.

Fit MLForecast on Source Domain

Feature engineering for cross-domain transfer

Because the model is trained on one domain and applied to another, the features must be scale-invariant. Tree models cannot extrapolate: if a Finance series has level changes larger than anything seen in the Macro training data, its predictions get clamped to the training range, producing large, skewed errors that no conformal correction can fully repair. We therefore model log-returns instead of raw differences:
  • GlobalSklearnTransformer(FunctionTransformer(np.log1p, np.expm1)) followed by Differences([1]) — the model sees relative changes, which live on a comparable scale in both domains. Back-transformed intervals scale multiplicatively with each series’ level.
  • Volatility and trend features (RollingStd, ExponentiallyWeightedMean, SeasonalRollingMean) — these sharpen the point forecasts and, importantly, give the density-ratio estimator meaningful covariates: on the raw scale, lag features mostly encode the scale difference between domains rather than the dynamics.

Prediction interval configuration

We fit on Macro series using PredictionIntervals with: - method='weighted_conformal_error' — stores lag features in the conformity score dataframe, enabling density-ratio estimation (DRE) for the weighted_conformal and scale_aligned_weighted transfer methods. - scale_estimator='mad' — stores per-series scale estimates (MAD of first differences), enabling the scale_aligned and scale_aligned_weighted transfer methods. Using this single fit configuration unlocks all five transfer methods.

Evaluate Transfer Methods

For each transfer method, we call mlf.predict() with: - new_df=target_train — the target domain training history (Finance series) - level=[80, 90, 95] — the requested coverage levels - transfer_conformal=method — which transfer strategy to use We then merge predictions with target_test and compute the empirical coverage at each level.

Results: Nominal vs Empirical Coverage

A well-calibrated method should have empirical coverage close to nominal. We show the results as a summary table and a bar chart.

Coverage Gap Analysis

Interval Width Analysis

Beyond coverage, we also care about interval sharpness. Narrower intervals (lower width) are better, as long as coverage is maintained.

Visual Inspection: Interval Examples

Let’s visually inspect the intervals produced by each method for a few target-domain series.

Summary

The table and charts above show how each transfer method calibrates prediction intervals when moving from a Macro source domain to a Finance target domain in M4 Monthly data. Key takeaways:
  • Feature engineering matters as much as the transfer method. Modeling log-returns (log1p + Differences([1])) instead of raw differences makes the features scale-invariant across domains, removes the systematic point-forecast bias, and is what allows the weighted methods to reach near-nominal coverage. With raw differences, every method under-covers by several percentage points.
  • recalibrate runs cross-validation on the target data — it tends to be the most directly calibrated but requires running CV (computationally equivalent to retraining).
  • scale_aligned uses the scale of the y signal (MAD of differences) to align source residuals — zero-shot, no CV needed.
  • error_scaled runs CV on the target data to estimate prediction error magnitude — a middle ground between full recalibration and scale alignment.
  • weighted_conformal uses density-ratio estimation to reweight source conformity scores — handles covariate shift without needing target labels during calibration.
  • scale_aligned_weighted combines scale alignment with DRE weighting — the most sophisticated zero-shot method.
  • The residual under-coverage of the non-weighted methods comes from pooling conformity scores across heterogeneous series: pooled intervals are too wide for calm series and too narrow for volatile ones. This is precisely the failure mode the weighted/scale-aligned variants are designed to mitigate.
The right method to use depends on your constraints: - If you can run CV on the target: recalibrate or error_scaled - If you need zero-shot transfer: scale_aligned or scale_aligned_weighted - If covariate shift is the main concern: weighted_conformal or scale_aligned_weighted