skills/cv/levenshtein-distance-metric/SKILL.md
Evaluates image-to-sequence models using mean Levenshtein edit distance between predicted and ground-truth strings.
npx skillsauth add wenmin-wu/ds-skills cv-levenshtein-distance-metricInstall 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 sequence generation tasks where output order matters (molecular formulas, OCR, LaTeX rendering), BLEU and accuracy are too coarse. Levenshtein (edit) distance counts the minimum insertions, deletions, and substitutions to transform the predicted string into the ground truth. Lower is better; 0 means exact match. Works at character or token level.
import Levenshtein
import numpy as np
def levenshtein_score(y_true, y_pred):
scores = []
for true, pred in zip(y_true, y_pred):
scores.append(Levenshtein.distance(true, pred))
return np.mean(scores)
# Usage:
preds = ["InChI=1S/C6H12O6", "InChI=1S/C2H6O"]
truth = ["InChI=1S/C6H12O6", "InChI=1S/C2H5OH"]
print(levenshtein_score(truth, preds)) # average edit distance
<eos>)python-Levenshtein is C-optimized; editdistance is an alternativedata-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