skills/llm/greedy-word-reinsert-search/SKILL.md
Greedy local search that removes one element from a fixed position and re-inserts it at every possible index, keeping the best improvement per round
npx skillsauth add wenmin-wu/ds-skills llm-greedy-word-reinsert-searchInstall 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.
A lightweight local search for sequence ordering: pick a position, remove the element, then try inserting it at every other position. Keep the best insertion if it improves the score. Sweep through all positions in one round. This is O(n^2) evaluations per round and converges in 3-10 rounds. Effective as a polishing step after coarser heuristics.
def greedy_reinsert(sequence, score_fn, max_rounds=10):
best = sequence[:]
best_score = score_fn(best)
for _ in range(max_rounds):
improved = False
for pos in range(len(best)):
elem = best[pos]
remaining = best[:pos] + best[pos+1:]
for insert_at in range(len(remaining) + 1):
candidate = remaining[:insert_at] + [elem] + remaining[insert_at:]
s = score_fn(candidate)
if s < best_score:
best = candidate
best_score = s
improved = True
break
if not improved:
break
return best, best_score
words = text.split()
result, score = greedy_reinsert(
words, lambda w: perplexity(' '.join(w)))
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