skills/cv/confidence-threshold-multilabel/SKILL.md
Assigns multiple labels per sample using a confidence threshold on sigmoid outputs with a fallback negative class.
npx skillsauth add wenmin-wu/ds-skills cv-confidence-threshold-multilabelInstall 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.
For multi-label classification, apply a confidence threshold to sigmoid outputs to assign zero or more labels per sample. Samples with no label above the threshold receive a fallback "Negative" class with confidence 1 - max_pred. Produces both label assignments and confidence scores per prediction.
import numpy as np
def multilabel_assign(probs, threshold=0.5, negative_class_id=18):
"""Assign labels from sigmoid probabilities with fallback.
Args:
probs: array of shape (n_classes,) with sigmoid outputs
threshold: confidence cutoff for positive assignment
negative_class_id: class ID for the fallback negative label
Returns:
list of (label_id, confidence) tuples
"""
assignments = []
for cls_id, p in enumerate(probs):
if p >= threshold:
assignments.append((cls_id, float(p)))
if not assignments:
assignments.append((negative_class_id, float(1.0 - probs.max())))
return assignments
def format_submission(cell_id, assignments, mask_rle):
"""Format as competition submission string."""
parts = []
for label_id, conf in assignments:
parts.append(f"{label_id} {conf:.4f} {mask_rle}")
return " ".join(parts)
1 - max_pred gives meaningful confidence for negative predictionsdata-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