skills/nlp/per-class-span-filtering/SKILL.md
Filters predicted NER spans using per-class minimum word-count and mean-probability thresholds to reduce false positives.
npx skillsauth add wenmin-wu/ds-skills nlp-per-class-span-filteringInstall 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.
NER models produce many short, low-confidence span predictions that are false positives. Different entity types have different natural lengths — an "Evidence" span should be at least 14 words, while a "Claim" can be as short as 3. Per-class filtering applies separate minimum length and confidence thresholds for each class, tuned on validation data. This simple post-processing step consistently improves F1 by 2-5 points.
import numpy as np
# Thresholds tuned on validation set
MIN_WORDS = {"Lead": 9, "Position": 5, "Evidence": 14,
"Claim": 3, "Concluding Statement": 11,
"Counterclaim": 6, "Rebuttal": 4}
MIN_PROBA = {"Lead": 0.70, "Position": 0.55, "Evidence": 0.65,
"Claim": 0.55, "Concluding Statement": 0.70,
"Counterclaim": 0.50, "Rebuttal": 0.55}
def filter_spans(predictions):
"""Filter spans by per-class length and probability thresholds.
predictions: list of (doc_id, class, word_indices_str, mean_proba)
"""
filtered = []
for doc_id, cls, pred_str, proba in predictions:
n_words = len(pred_str.split())
if n_words >= MIN_WORDS.get(cls, 1) and proba >= MIN_PROBA.get(cls, 0.5):
filtered.append((doc_id, cls, pred_str))
return filtered
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