skills/cv/pairwise-distance-proximity-filter/SKILL.md
Compute Euclidean distance between entity pairs from tracking data and filter out pairs beyond a threshold to reduce inference candidates
npx skillsauth add wenmin-wu/ds-skills cv-pairwise-distance-proximity-filterInstall 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.
In pairwise interaction detection (player contact, vehicle collision, person re-id), most entity pairs at any given timestep are too far apart to interact. Computing Euclidean distance from tracking/GPS coordinates and filtering pairs beyond a threshold (e.g., 2 yards) removes 80-95% of negative candidates before expensive model inference, dramatically reducing compute and false positive rate.
import numpy as np
import pandas as pd
def filter_by_distance(df, pos_cols_1, pos_cols_2, threshold=2.0):
"""Filter entity pairs by Euclidean distance.
df: DataFrame with position columns for both entities
"""
valid = df[pos_cols_2[0]].notnull()
dist = np.full(len(df), np.nan)
dist[valid] = np.sqrt(
np.square(df.loc[valid, pos_cols_1[0]] - df.loc[valid, pos_cols_2[0]])
+ np.square(df.loc[valid, pos_cols_1[1]] - df.loc[valid, pos_cols_2[1]])
)
df['distance'] = dist
return df.query('not distance > @threshold').reset_index(drop=True)
filtered = filter_by_distance(
df_pairs,
['x_position_1', 'y_position_1'],
['x_position_2', 'y_position_2'],
threshold=2.0
)
not distance > T keeps NaN rows; distance <= T drops themdata-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