Algorithm Optimization Skill
Systematic workflow to improve algorithms or process flows using real input data and target metrics, without harming already-good performance.
When to Use
- Optimizing an algorithm or multi-step process against clear metrics
- Improving confidence, accuracy, precision, recall, or similar quality KPIs on labeled/real cases
- Diagnosing why some cases perform poorly
- Iteratively fixing weak cases while protecting strong ones
When Not to Use
- No input dataset or no measurable metric
- Pure conceptual discussion without evaluation data
- Runtime latency/CPU/memory tuning (
python-performance)
- One-off code cleanup unrelated to quality metrics
Required Inputs
- Input dataset (or representative samples)
- Target metrics to optimize (e.g. confidence score, accuracy, F1, error rate)
- Current algorithm/process to evaluate
- Definition of "low performance" threshold when available
Optimization Loop
Step 1: Run Baseline
- Run the algorithm/process on the input data
- Collect outputs and metric values for each case
Step 2: Evaluate Performance
- Compute overall metrics
- Rank or segment cases by performance
Step 3: Filter Low Performance
- Isolate cases below the accepted threshold
- Keep high-performance cases as a regression guardrail
Step 4: Classify Failure Cause
For each low-performance group, classify:
- Input data issue (noise, labeling error, missing fields, invalid format)
→ Document and report; do not force algorithm changes for bad data
- Algorithm / process issue
→ Continue to Step 5
Step 5: Deep Analysis
- Investigate root causes in the algorithm/process
- Identify failure patterns (edge cases, feature gaps, brittle rules, weak models, bad thresholds, pipeline order issues)
- Search for candidate fixes (logic changes, features, parameters, alternative methods)
Step 6: Plan Safe Improvements
- Propose targeted fixes for the weak cases
- Explicitly check risk to already-good cases
- Prefer changes that are localized, testable, and reversible
- Define success criteria before implementing
Step 7: Implement, Re-run, and Verify
- Apply the planned improvement
- Re-evaluate on:
- Previously low-performance cases
- Previously good-performance cases (regression check)
- Outcomes:
- Improved and no major regression → proceed to Step 8
- Not improved or unclear → return to Step 4/5 with new evidence
- Regression on good cases → revise or roll back the change
Step 8: Report
Default: in-chat baseline vs after table (weak cases + healthy-case regression).
Load technical-reporting only if the user asked for a saved markdown file. Cover: baseline, cause classification, changes, before/after, residual risk.
Guardrails
- Isolate Root-Cause First: Always complete diagnostic root-cause isolation before coding fixes.
- Strict Separation: Rigorously separate data quality issues (noise, labels, format) from algorithm/process logic issues — never mutate algorithm logic to patch bad data.
- Regression Protection: Never optimize only on failing cases without validating against healthy baseline cases.
- Incremental Changes: Prefer incremental, evidence-based changes over large rewrites.
- Stopping Rule: Stop when metric targets are met or gains are no longer worth the added complexity.
Related Skills
- Use data-science for statistical diagnosis of failure groups.
- Use python-performance when the bottleneck is runtime/memory/I/O, not quality KPIs.
- Use data-visualization for before/after KPI charts. Saved markdown only if requested (
technical-reporting).
Final Checklist
1---2name: algorithm-optimization3description: Improve quality KPIs (accuracy, F1, error rate) on real cases while protecting healthy ones. Not for Python runtime/memory profiling.4---56# Algorithm Optimization Skill78Systematic workflow to improve algorithms or process flows using real input data and target metrics, without harming already-good performance.910## When to Use11- Optimizing an algorithm or multi-step process against clear metrics12- Improving confidence, accuracy, precision, recall, or similar **quality** KPIs on labeled/real cases13- Diagnosing why some cases perform poorly14- Iteratively fixing weak cases while protecting strong ones1516## When Not to Use17- No input dataset or no measurable metric18- Pure conceptual discussion without evaluation data19- Runtime latency/CPU/memory tuning (`python-performance`)20- One-off code cleanup unrelated to quality metrics2122## Required Inputs23- Input dataset (or representative samples)24- Target metrics to optimize (e.g. confidence score, accuracy, F1, error rate)25- Current algorithm/process to evaluate26- Definition of "low performance" threshold when available2728## Optimization Loop2930### Step 1: Run Baseline31- Run the algorithm/process on the input data32- Collect outputs and metric values for each case3334### Step 2: Evaluate Performance35- Compute overall metrics36- Rank or segment cases by performance3738### Step 3: Filter Low Performance39- Isolate cases below the accepted threshold40- Keep high-performance cases as a regression guardrail4142### Step 4: Classify Failure Cause43For each low-performance group, classify:4445- **Input data issue** (noise, labeling error, missing fields, invalid format)46 → Document and report; do not force algorithm changes for bad data47- **Algorithm / process issue**48 → Continue to Step 54950### Step 5: Deep Analysis51- Investigate root causes in the algorithm/process52- Identify failure patterns (edge cases, feature gaps, brittle rules, weak models, bad thresholds, pipeline order issues)53- Search for candidate fixes (logic changes, features, parameters, alternative methods)5455### Step 6: Plan Safe Improvements56- Propose targeted fixes for the weak cases57- Explicitly check risk to already-good cases58- Prefer changes that are localized, testable, and reversible59- Define success criteria before implementing6061### Step 7: Implement, Re-run, and Verify62- Apply the planned improvement63- Re-evaluate on:64 1. Previously low-performance cases65 2. Previously good-performance cases (regression check)66- Outcomes:67 - Improved and no major regression → proceed to Step 868 - Not improved or unclear → return to Step 4/5 with new evidence69 - Regression on good cases → revise or roll back the change7071### Step 8: Report72Default: in-chat baseline vs after table (weak cases + healthy-case regression).73Load **technical-reporting** only if the user asked for a saved markdown file. Cover: baseline, cause classification, changes, before/after, residual risk.7475## Guardrails76- **Isolate Root-Cause First**: Always complete diagnostic root-cause isolation before coding fixes.77- **Strict Separation**: Rigorously separate data quality issues (noise, labels, format) from algorithm/process logic issues — never mutate algorithm logic to patch bad data.78- **Regression Protection**: Never optimize only on failing cases without validating against healthy baseline cases.79- **Incremental Changes**: Prefer incremental, evidence-based changes over large rewrites.80- **Stopping Rule**: Stop when metric targets are met or gains are no longer worth the added complexity.8182## Related Skills83- Use **data-science** for statistical diagnosis of failure groups.84- Use **python-performance** when the bottleneck is runtime/memory/I/O, not quality KPIs.85- Use **data-visualization** for before/after KPI charts. Saved markdown only if requested (`technical-reporting`).8687## Final Checklist88- [ ] Baseline run completed and metrics collected89- [ ] Low-performance cases filtered with a clear threshold90- [ ] Failures classified as data vs algorithm/process91- [ ] Root-cause analysis completed before coding fixes92- [ ] Improvement plan protects existing good performance93- [ ] Changes re-evaluated on both weak and strong cases94- [ ] Final report includes baseline, analysis, changes, and results