ml-hyperparameter-tuning
БесплатноБез исполняемых скриптовНе проверенThis skill should be used when the user asks to tune hyperparameters, run sweeps, optimize search spaces, or use AutoML. PROACTIVELY activate for: (1) Optuna…
от JosiahSiegel★ 67 звёзд на GitHubОб этом скилле
ML Hyperparameter Tuning
Overview
Use this skill for designing and running hyperparameter searches. Tuning should improve a valid baseline under a fixed evaluation protocol. Do not tune before data validation, leakage-safe splits, metric selection, reproducible training, and a simple baseline are in place.
Search Strategy Selection
| Strategy | Use when | Notes |
|---|---|---|
| Manual informed search | Early debugging or very small budgets | Best when guided by learning curves and domain knowledge |
| Grid search | Few categorical/discrete parameters | Wasteful in high dimensions |
| Random search | Strong default for broad spaces | Often beats grid when only some parameters matter |
| Bayesian/TPE | Moderate budgets and expensive trials | Good for structured continuous/discrete spaces |
| Hyperband/ASHA | Many deep-learning trials with early signal | Requires comparable learning curves and sensible early-stopping metric |
| Population-based training | Schedules and nonstationary hyperparameters | More complex; useful for RL and large training budgets |
| AutoML | Need strong baseline or tabular productivity | Validate leakage, explainability, and deployment constraints |
Optuna is a flexible default for Python search. Ray Tune is strong for distributed sweeps, schedulers, and Ray Train integration. FLAML emphasizes cost-effective AutoML. AutoGluon is productive for tabular, multimodal, and time-series baselines. W&B sweeps integrate well with experiment tracking.
Optuna Objective with Pruning (Python Blueprint)
Optuna allows pruning unpromising trials early in the training loop based on intermediate validation scores.
import optuna
import torch
import torch.nn as nn
import torch.optim as optim
def train_and_validate(config, trial, model, train_loader, val_loader, device):
criterion = nn.CrossEntropyLoss()
optimizer = optim.Adam(model.parameters(), lr=config["lr"])
for epoch in range(10): # 10 Epochs max
model.train()
for inputs, targets in train_loader:
inputs, targets = inputs.to(device), targets.to(device)
optimizer.zero_grad()
outputs = model(inputs)
loss = criterion(outputs, targets)
loss.backward()
optimizer.step()
# Validation epoch
model.eval()
val_loss = 0.0
with torch.no_grad():
for inputs, targets in val_loader:
inputs, targets = inputs.to(device), targets.to(device)
outputs = model(inputs)
val_loss += criterion(outputs, targets).item()
val_loss /= len(val_loader)
# Report intermediate value to Optuna for pruning check
trial.report(val_loss, epoch)
# Handle pruning (stop execution of this trial if criteria are met)
if trial.should_prune():
raise optuna.exceptions.TrialPruned()
return val_loss
def objective(trial: optuna.Trial, model_class, train_loader, val_loader, device):
# Search Space Configuration
config = {
"lr": trial.suggest_float("lr", 1e-5, 1e-2, log=True),
"optimizer": trial.suggest_categorical("optimizer", ["Adam", "SGD", "RMSprop"]),
"batch_size": trial.suggest_categorical("batch_size", [16, 32, 64]),
"dropout_rate": trial.suggest_float("dropout_rate", 0.1, 0.5)
}
model = model_class(dropout_rate=config["dropout_rate"]).to(device)
return train_and_validate(config, trial, model, train_loader, val_loader, device)
# Running the study
# study = optuna.create_study(direction="minimize", pruner=optuna.pruners.MedianPruner())
# study.optimize(lambda t: objective(t, MyModel, train_loader, val_loader, device), n_trials=50)
Search Space Design
Use distributions that reflect scale. Learning rate, weight decay, regularization strength, and tree min child weights usually need log-uniform or categorical log grids. Depth, layers, hidden sizes, batch size, and number of estimators are discrete. Optimizer, scheduler, augmentation policy, model family, and feature set are categorical.
Avoid searching invalid combinations. Encode conditional spaces: max_depth only for tree models, LoRA rank only for PEFT, warmup ratio only for scheduled optimizers. Keep the first search broad and shallow; narrow around promising regions.
Weights & Biases (W&B) Sweep YAML Blueprint (sweep.yaml)
W&B Sweeps run hyperparameter searches across multiple distributed agents.
program: train.py
method: bayes # Search algorithm: bayes, random, grid
metric:
name: val_loss
goal: minimize
parameters:
learning_rate:
distribution: log_uniform_values
min: 1e-5
max: 1e-2
batch_size:
values: [16, 32, 64]
epochs:
value: 20
dropout:
distribution: uniform
min: 0.1
max: 0.5
optimizer:
values: ["adam", "adamw", "sgd"]
early_terminate:
type: hyperband
min_iter: 3
eta: 2
Ray T
Установить ml-hyperparameter-tuning в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл ml-hyperparameter-tuning?
This skill should be used when the user asks to tune hyperparameters, run sweeps, optimize search spaces, or use AutoML. PROACTIVELY activate for: (1) Optuna, Ray Tune, FLAML, AutoGluon, Hyperopt, Nevergrad, KerasTuner, W&B sweeps, (2) grid search, random search, Bayesian optimization, TPE, Gaussian processes, evolutionary search, (3) ASHA, Hyperband, successive halving, multi-fidelity optimization, population-based training, (4) learning-rate finder, batch-size search, early stopping, pruning, (5) reproducible sweep design and experiment analysis. Provides: budget-aware hyperparameter search strategy.
Как установить скилл ml-hyperparameter-tuning?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл ml-hyperparameter-tuning запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic