skills/tabular/weather-ordinal-encoding/SKILL.md
Map free-text categorical descriptions to ordinal numeric scores via keyword matching — captures ordered severity in a single dense feature
npx skillsauth add wenmin-wu/ds-skills tabular-weather-ordinal-encodingInstall 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.
Free-text categorical fields with inherent ordering (weather, severity, quality) can be encoded as a single ordinal score via keyword matching. Map keywords to numeric values that reflect the ordering (e.g., sunny=2, cloudy=−1, rain=−2). Handles typos and compound descriptions (e.g., "partly cloudy") via multiplicative modifiers.
import pandas as pd
import numpy as np
def encode_ordinal_text(text, keyword_scores, modifiers=None):
"""Map free-text to ordinal score via keyword matching.
Args:
text: raw text string
keyword_scores: dict of keyword → score, checked in order
modifiers: dict of keyword → multiplier (e.g., 'partly' → 0.5)
"""
if pd.isna(text):
return 0
text = text.lower().strip()
score = 1.0
if modifiers:
for kw, mult in modifiers.items():
if kw in text:
score *= mult
for kw, val in keyword_scores.items():
if kw in text:
return score * val
return 0
# Weather encoding
weather_scores = {
'indoor': 3, 'climate controlled': 3,
'sunny': 2, 'sun': 2, 'clear': 1,
'cloudy': -1, 'overcast': -1,
'rain': -2, 'rainy': -2, 'showers': -2,
'snow': -3, 'blizzard': -3,
}
modifiers = {'partly': 0.5, 'light': 0.5}
df['weather_score'] = df['GameWeather'].apply(
lambda x: encode_ordinal_text(x, weather_scores, modifiers)
)
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