skills/tabular/per-feature-bias-correction/SKILL.md
Post-processing correction for multi-output regression — scale each output by its train-derived mean ratio to fix systematic per-feature bias
npx skillsauth add wenmin-wu/ds-skills tabular-per-feature-bias-correctionInstall 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.
Multi-output models often have systematic per-feature biases (some outputs consistently over/under-predicted). Compute the mean ratio of true labels to OOF predictions per output on training data, then apply as a multiplicative correction to test predictions. Clip extreme corrections to avoid amplifying noise.
import numpy as np
def compute_bias_scales(y_true, y_pred, clip_range=(0.99, 1.01)):
"""Compute per-feature correction scales from OOF predictions.
Args:
y_true: (N, K) ground truth
y_pred: (N, K) OOF predictions
clip_range: (lo, hi) to prevent extreme corrections
"""
with np.errstate(divide='ignore', invalid='ignore'):
scales = np.nanmean(y_true / y_pred, axis=0)
scales = np.clip(scales, *clip_range)
scales[np.isnan(scales)] = 1.0
return scales
def apply_bias_correction(predictions, scales):
return predictions * scales[np.newaxis, :]
# Usage
scales = compute_bias_scales(train_labels, oof_predictions)
test_corrected = apply_bias_correction(test_predictions, scales)
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