skills/tabular/logspace-recency-reranking/SKILL.md
Rerank session candidates using log-spaced recency weights multiplied by interaction-type multipliers
npx skillsauth add wenmin-wu/ds-skills tabular-logspace-recency-rerankingInstall 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.
When reranking items from a user's session history, assign weights that grow logarithmically from oldest to newest event. Multiply by interaction-type multipliers (orders > carts > clicks) so recent high-intent actions dominate. Accumulate weighted scores per item via Counter and return top-K.
import numpy as np
from collections import Counter
def rerank_by_recency(aids, types, type_multipliers={0:1, 1:6, 2:3},
top_k=20):
"""Rerank candidates with logspace recency + type weights.
Args:
aids: list of item IDs in chronological order
types: list of interaction types (0=click, 1=cart, 2=order)
type_multipliers: weight per interaction type
top_k: number of items to return
"""
weights = np.logspace(0.1, 1, len(aids), base=2, endpoint=True) - 1
scores = Counter()
for aid, w, t in zip(aids, weights, types):
scores[aid] += w * type_multipliers[t]
return [aid for aid, _ in scores.most_common(top_k)]
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