skills/timeseries/quantile-ratio-scaling/SKILL.md
Convert point forecasts to prediction intervals by scaling with logit-transformed quantile ratios passed through a Normal CDF
npx skillsauth add wenmin-wu/ds-skills timeseries-quantile-ratio-scalingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Instead of training separate models for each quantile, convert a single point (median) forecast into a full set of prediction intervals. Apply the logit transform log(q/(1-q)) to each target quantile, scale by a bandwidth coefficient, pass through the Normal CDF, and normalize so the median ratio equals 1.0. Multiplying point forecasts by these ratios produces calibrated quantile predictions at zero additional training cost.
import numpy as np
from scipy import stats
import pandas as pd
def get_quantile_ratios(quantiles, coef=0.065):
"""Compute multiplicative ratios for converting point forecasts to quantiles."""
qs = np.array(quantiles)
logit_qs = np.log(qs / (1 - qs)) * coef
ratios = stats.norm.cdf(logit_qs)
ratios /= ratios[len(ratios) // 2] # normalize so median = 1.0
return pd.Series(ratios, index=qs)
quantiles = [0.005, 0.025, 0.165, 0.25, 0.5, 0.75, 0.835, 0.975, 0.995]
ratios = get_quantile_ratios(quantiles, coef=0.065)
# Apply to point forecasts
for q in quantiles:
forecast_q = point_forecast * ratios[q]
log(q / (1-q)) for each quantiledata-ai
Scaled Pinball Loss (SPL) metric for evaluating quantile forecasts, normalized by mean absolute successive differences of training data
data-ai
Walk backward through a time series and multiplicatively rescale segments when jumps exceed a fraction of the running mean to correct data collection anomalies
testing
Transform forecasting target to next/current ratio minus one so that optimizing MAE or squared error implicitly minimizes SMAPE
testing
Use scipy periodogram to identify dominant seasonal frequencies in a time series before selecting Fourier feature orders or ARIMA seasonal parameters