skills/nlp/label-smoothing-binary/SKILL.md
Applies label smoothing to binary cross-entropy loss to reduce overconfidence and improve generalization in text classification.
npx skillsauth add wenmin-wu/ds-skills nlp-label-smoothing-binaryInstall 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.
Replace hard labels (0/1) with softened labels (ε, 1-ε) during training. This prevents the model from becoming overconfident on training examples, acts as implicit regularization, and improves calibration of predicted probabilities. Especially useful in text classification where boundary examples are ambiguous.
# Keras / TensorFlow
import tensorflow as tf
loss = tf.keras.losses.BinaryCrossentropy(label_smoothing=0.02)
model.compile(optimizer='adam', loss=loss, metrics=['accuracy'])
# PyTorch (manual)
import torch
import torch.nn.functional as F
def smooth_bce(preds, targets, smoothing=0.02):
"""Binary cross-entropy with label smoothing."""
targets = targets * (1 - smoothing) + 0.5 * smoothing
return F.binary_cross_entropy_with_logits(preds, targets)
# Usage in training loop
loss = smooth_bce(logits, labels, smoothing=0.02)
loss.backward()
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