skills/timeseries/tof-spatial-region-pooling/SKILL.md
Aggregate high-dimensional spatial sensor grids into hierarchical region statistics at multiple granularities
npx skillsauth add wenmin-wu/ds-skills timeseries-tof-spatial-region-poolingInstall 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.
Spatial sensors (Time-of-Flight, depth cameras, pressure mats) produce pixel grids per timestep. Reduce dimensionality by pooling pixels into spatial regions at multiple scales (2, 4, 8, 16, 32 regions), computing mean/std/min/max per region. Captures both coarse and fine spatial patterns.
import numpy as np
import pandas as pd
def spatial_region_pooling(pixel_df, n_pixels=64, scales=[2, 4, 8, 16, 32],
sentinel=-1):
"""Pool pixel grid into multi-scale region statistics."""
data = pixel_df.replace(sentinel, np.nan)
features = {}
# Global stats
features['mean'] = data.mean(axis=1)
features['std'] = data.std(axis=1)
# Multi-scale regions
for n_regions in scales:
region_size = n_pixels // n_regions
for r in range(n_regions):
region = data.iloc[:, r * region_size:(r + 1) * region_size]
features[f'r{n_regions}_{r}_mean'] = region.mean(axis=1)
features[f'r{n_regions}_{r}_std'] = region.std(axis=1)
features[f'r{n_regions}_{r}_min'] = region.min(axis=1)
features[f'r{n_regions}_{r}_max'] = region.max(axis=1)
return pd.DataFrame(features, index=pixel_df.index)
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