skills/timeseries/scaled-nan-sentinel/SKILL.md
Encode missing sensor data with a per-modality sentinel value that survives standardization and remains detectable after scaling
npx skillsauth add wenmin-wu/ds-skills timeseries-scaled-nan-sentinelInstall 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.
StandardScaler transforms NaN-replacement values unpredictably. Instead, set a sentinel as a negative multiple of the modality's max value, then precompute what this sentinel becomes after scaling. The model can learn to detect the scaled sentinel as "missing" without NaN handling in the forward pass.
import numpy as np
from sklearn.preprocessing import StandardScaler
class SentinelScaler:
def __init__(self, ratio=3.0):
self.ratio = ratio
self.scaler = StandardScaler()
self.sentinel_raw = {}
self.sentinel_scaled = {}
def fit(self, data, modality_cols):
"""Fit scaler and compute sentinel values per modality."""
for name, cols in modality_cols.items():
max_val = data[cols].max().max()
self.sentinel_raw[name] = -max_val * self.ratio
filled = data.copy()
for name, cols in modality_cols.items():
filled[cols] = filled[cols].fillna(self.sentinel_raw[name])
self.scaler.fit(filled)
# Precompute scaled sentinel
for name, cols in modality_cols.items():
dummy = np.full((1, len(filled.columns)), 0.0)
idx = [filled.columns.get_loc(c) for c in cols]
for i in idx:
dummy[0, i] = self.sentinel_raw[name]
scaled = self.scaler.transform(dummy)
self.sentinel_scaled[name] = np.mean(scaled[0, idx])
def transform(self, data, modality_cols):
filled = data.copy()
for name, cols in modality_cols.items():
filled[cols] = filled[cols].fillna(self.sentinel_raw[name])
return self.scaler.transform(filled)
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