skills/timeseries/poisson-lgbm-bias-corrected-ensemble/SKILL.md
Train a single Poisson LightGBM count forecaster, then ensemble its predictions with multiple multiplicative scaling factors (alpha ≈ 1.02-1.03) to undo the systematic downward bias of Poisson regression on intermittent retail data
npx skillsauth add wenmin-wu/ds-skills timeseries-poisson-lgbm-bias-corrected-ensembleInstall 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.
Poisson regression LightGBM is the right objective for non-negative count forecasting (sales, clicks, visits) because it naturally produces non-negative predictions and handles the count distribution. But it has a known systematic flaw: on intermittent / zero-inflated data, the trained model consistently predicts means a few percent below the true conditional mean, because the loss surface around zero is asymmetric and the optimizer settles into a slightly conservative basin. The fix is embarrassingly simple: train one model, then "ensemble" it with itself by applying a small set of multiplicative scaling factors, one per ensemble member. Average their predictions and you get a bias-corrected forecast at zero extra training cost.
import lightgbm as lgb
import numpy as np
params = {
'objective': 'poisson',
'metric': 'rmse',
'learning_rate': 0.075,
'sub_row': 0.75,
'bagging_freq': 1,
'lambda_l2': 0.1,
'num_leaves': 128,
'min_data_in_leaf': 100,
'num_iterations': 1200,
}
model = lgb.train(params, train_data, valid_sets=[valid_data])
base = model.predict(X_test)
alphas = [1.018, 1.023, 1.028] # tuned on validation
preds = np.mean([a * base for a in alphas], axis=0)
actual.sum() / pred.sum() — typically 1.02-1.04[1.018, 1.023, 1.028] for a center of 1.023)variance_power < 1.2; if you're already on Tweedie, you don't need this trick.data-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
tools
Convert point forecasts to prediction intervals by scaling with logit-transformed quantile ratios passed through a Normal CDF