hyperparameter-tuning
Skill11 starsChanged 6 months agoMITView on GitHub
Use when optimizing model hyperparameters. Covers search strategy (random vs Bayesian/Optuna), leakage-safe tuning inside CV, search-space design, early stopping, and budget management.
In this repository14 other files it gives its agents.
- data-cleaningSkill
- experiment-trackingSkill
- exploratory-data-analysisSkill
- feature-engineeringSkill
- imbalanced-dataSkill
- llm-finetuningSkill
- ml-debuggingSkill
- model-evaluationSkill
- model-servingSkill
- pandas-patternsSkill
- pytorch-training-loopSkill
- rag-pipelineSkill
- reproducible-mlSkill
- sklearn-pipelinesSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 55
Start wide, then narrow around the best region in a second study.
- Distinctive: line 63
Don't tune dozens of params — pick the 3-5 that matter for your model family.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Hyperparameter Tuning
Overview
Tuning squeezes the last 5-15% out of a model — but done carelessly it overfits the validation set and leaks preprocessing. The rules: tune the whole pipeline inside cross-validation, search smart (not grid), and keep a final untouched test set.
When to use
- A reasonable baseline exists and you want to improve it.
- You need to pick model complexity (depth, regularization, lr).
Strategy selection
| Situation | Method |
| Few params, cheap model | GridSearchCV |
| Many params / continuous | RandomizedSearchCV (often beats grid per compute) |
| Expensive model, want efficiency | Bayesian / Optuna (TPE) |
| Neural nets | Optuna + early stopping + pruning |
Optuna pattern (leakage-safe, prunes bad trials)
import optuna
from sklearn.model_selection import cross_val_score, StratifiedKFold
cv = StratifiedKFold(5, shuffle=True, random_state=42)
def objective(trial):
params = {
"clf__learning_rate": trial.suggest_float("lr", 1e-3, 0.3, log=True),
"clf__max_depth": trial.suggest_int("max_depth", 3, 12),
"clf__l2_regularization": trial.suggest_float("l2", 1e-3, 10, log=True),
}
model.set_params(**params)
scores = cross_val_score(model, X_train, y_train, cv=cv, scoring="roc_auc")
return scores.mean()
study = optuna.create_study(direction="maximize",
sampler=optuna.samplers.TPESampler(seed=42))
study.optimize(objective, n_trials=50, timeout=1800)
print(study.best_params, study.best_value)Note the clf__ prefix — you're tuning the estimator inside the pipeline, so preprocessing re-fits per fold.
Search-space design
- Sample learning rates and regularization on a log scale.
- Start wide, then narrow around the best region in a second study.
- Tie
n_estimatorsto early stopping rather than tuning it directly. - Fix the seed in the sampler for reproducible studies.
Budget management
- Set
timeoutandn_trialsceilings; use Optuna pruning to kill hopeless trials early. - Tune on a representative subsample first to find the region, then refine on full data.
- Don't tune dozens of params — pick the 3-5 that matter for your model family.
Pitfalls
- Nested leakage: preprocessing fit outside CV, then tuned — inflates scores. Tune the pipeline.
- Tuning on the test set — only ever touch train/validation; report final number on the holdout once.
- Over-tuning to a tiny validation set → great CV, worse production. Prefer simpler models + regularization.
- Comparing tuned-vs-untuned across different CV splits — keep the split fixed.
Hand-off
Best params + a refit pipeline, logged via experiment-tracking and scored once on the holdout via model-evaluation.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

