setup-automl-pipeline
关于
This skill automates hyperparameter optimization using Optuna or Ray Tune, implementing strategies like Hyperband and ASHA with early stopping. It helps developers quickly find optimal model configurations when starting projects, retraining models, or comparing algorithms with minimal manual tuning. Use it to efficiently define search spaces and automate the tuning process.
快速安装
Claude Code
推荐npx skills add pjt222/agent-almanac -a claude-code/plugin add https://github.com/pjt222/agent-almanacgit clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/setup-automl-pipeline在 Claude Code 中复制并粘贴此命令以安装该技能
技能文档
Setup AutoML Pipeline
See Extended Examples for complete configuration files and templates.
Automate hyperparameter tuning and model selection using Optuna or Ray Tune with efficient search strategies.
Cuándo Usar
- Starting new ML project and need to quickly find good model configurations
- Retraining existing model with new data and want to re-optimize hyperparameters
- Comparing multiple algorithms and their optimal configurations
- Limited time for manual tuning but need near-optimal performance
- Team lacks deep expertise in specific algorithm hyperparameters
- Need reproducible and documented optimization process
Entradas
- Requerido: Training dataset with features and labels
- Requerido: Validation dataset for objective evaluation
- Requerido: Model type(s) to optimize (e.g., XGBoost, LightGBM, neural network)
- Requerido: Optimization objective (metric to maximize/minimize)
- Requerido: Compute budget (time or number of trials)
- Opcional: Search space constraints (min/max values for hyperparameters)
- Opcional: Prior knowledge of good hyperparameter ranges
Procedimiento
Paso 1: Install Dependencies and Set Up Environment
Install Optuna or Ray Tune with appropriate backends.
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Option 1: Optuna (simpler, good for single-machine)
pip install optuna optuna-dashboard
pip install scikit-learn xgboost lightgbm
# Option 2: Ray Tune (distributed, good for multi-machine/GPU)
pip install "ray[tune]" optuna hyperopt bayesian-optimization
pip install torch torchvision # if optimizing neural networks
# Visualization and tracking
pip install mlflow tensorboard plotly
Create project structure:
mkdir -p automl/{configs,experiments,models,results}
Esperado: Clean environment with required packages installed, no dependency conflicts.
En caso de fallo: Use Python 3.8-3.11 (compatibility issues with 3.12+), if CUDA errors occur install CPU-only versions first, on M1/M2 Mac use conda instead of pip for scikit-learn.
Paso 2: Define Search Space and Objective (Optuna)
Create configuration for hyperparameter search.
# automl/optuna_config.py
import optuna
from optuna.pruners import HyperbandPruner
from optuna.samplers import TPESampler
import xgboost as xgb
from sklearn.metrics import roc_auc_score, mean_squared_error
import numpy as np
# ... (see EXAMPLES.md for complete implementation)
Esperado: Search space covers reasonable hyperparameter ranges, objective function runs without errors, pruning stops unpromising trials early.
En caso de fallo: If trials crash, reduce search space (e.g., lower max n_estimators), verify data has no NaN/inf values, check memory usage (reduce batch size if OOM), ensure eval_metric matches task type.
Paso 3: Run Optimization with Advanced Samplers
Execute hyperparameter search with efficient sampling strategies.
# automl/run_optimization.py
import optuna
from optuna.samplers import TPESampler, CmaEsSampler, NSGAIISampler
from optuna.pruners import HyperbandPruner, MedianPruner, SuccessiveHalvingPruner
import joblib
import pandas as pd
from pathlib import Path
# ... (see EXAMPLES.md for complete implementation)
Esperado: Optimization completes with 50-70% of trials pruned early, best parameters found, visualization plots generated showing convergence.
En caso de fallo: If no pruning happens, verify objective reports intermediate values correctly, if optimization doesn't improve try different sampler (TPE → CmaES), if crashes with n_jobs>1 use n_jobs=1 for debugging.
Paso 4: Set Up Ray Tune for Distributed Optimization (Alternative)
Use Ray Tune for multi-GPU or multi-node optimization.
# automl/ray_tune_config.py
from ray import tune
from ray.tune.schedulers import ASHAScheduler, PopulationBasedTraining
from ray.tune.search.optuna import OptunaSearch
from ray.tune.search import ConcurrencyLimiter
import xgboost as xgb
from sklearn.metrics import roc_auc_score
import os
# ... (see EXAMPLES.md for complete implementation)
Esperado: Ray Tune runs trials in parallel across CPUs/GPUs, ASHA scheduler stops bad trials early, best configuration found and logged.
En caso de fallo: If Ray crashes, start with ray.init(num_cpus=2, num_gpus=0) for debugging, reduce concurrent trials if OOM, check that train function doesn't modify shared data, use tune.report() not return for metrics.
Paso 5: Track Experiments with MLflow
Integrate with MLflow for experiment tracking and model registry.
# automl/mlflow_tracking.py
import mlflow
import mlflow.xgboost
from mlflow.tracking import MlflowClient
import optuna
from pathlib import Path
# ... (see EXAMPLES.md for complete implementation)
Esperado: All trials logged to MLflow with parameters and metrics, best model registered in MLflow registry, experiments viewable in MLflow UI.
En caso de fallo: Start MLflow UI with mlflow ui --backend-store-uri file:./automl/mlruns, check write permissions to mlruns directory, if registration fails verify model registry is configured, ensure model artifact size < 2GB.
Paso 6: Deploy Best Model and Monitor Performance
Save optimized model and set up monitoring.
# automl/deploy_model.py
import joblib
import json
from pathlib import Path
import optuna
import xgboost as xgb
# ... (see EXAMPLES.md for complete implementation)
Esperado: Model saved in production-ready format, configuration documented, inference script created for deployment.
En caso de fallo: If model file too large (>100MB), consider model compression or feature selection, verify model loads correctly in fresh Python session, test inference script with sample data before deployment.
Validación
- Optuna/Ray Tune installs without dependency conflicts
- Search space includes reasonable hyperparameter ranges
- Objective function runs successfully for single trial
- Optimization completes 50+ trials within time budget
- Pruning stops 40-70% of unpromising trials early
- Best parameters improve over default configuration by >5%
- Visualizations show convergence (optimization history flattens)
- MLflow logs all trials with parameters and metrics
- Final model saved and loads correctly
- Deployment package includes all necessary files
Errores Comunes
- Overfitting to validation set: Running 1000s of trials implicitly optimizes for validation set; use holdout test set or time-based split for final evaluation
- Ignoring feature engineering: AutoML finds best hyperparameters but doesn't create features; invest in feature engineering first
- Search space too wide: Unbounded or very wide ranges waste trials on unrealistic values; use domain knowledge to constrain
- Not using early stopping: Training full epochs for every trial is wasteful; enable early stopping in objective function
- Ignoring compute costs: 100 trials × 10 minutes = 16 hours; consider compute budget when setting n_trials
- Categorical features not encoded: Most algorithms need numeric features; encode categoricals before optimization
- Imbalanced data: Default metrics may mislead with class imbalance; use F1, AUC, or custom metrics
- Not saving intermediate results: Crashes lose all progress; use persistent storage (Optuna SQLite, MLflow) to resume
Habilidades Relacionadas
track-ml-experiments- MLflow experiment tracking and versioningorchestrate-ml-pipeline- Airflow/Kubeflow for production AutoML pipelines
GitHub 仓库
相关推荐技能
executing-plans
设计该Skill用于当开发者提供完整实施计划时,以受控批次方式执行代码实现。它会先审阅计划并提出疑问,然后分批次执行任务(默认每批3个任务),并在批次间暂停等待审查。关键特性包括分批次执行、内置检查点和架构师审查机制,确保复杂系统实现的可控性。
requesting-code-review
设计该Skill可在完成任务、实现主要功能或合并代码前自动调度代码审查子代理,确保实现符合需求和计划。它支持通过指定git SHA范围进行精准的代码变更审查,帮助开发者在关键节点及时发现潜在问题。核心原则是"早审查、勤审查",适用于开发流程的各个关键阶段。
connect-mcp-server
设计这个Skill指导开发者如何将MCP服务器连接到Claude Code,支持HTTP、stdio和SSE三种传输协议。它涵盖了从安装配置到认证安全的完整流程,适用于集成GitHub、Notion、数据库等外部服务。当开发者需要添加集成、配置外部工具或提及MCP相关功能时,这个Skill能提供实用的操作指南。
web-cli-teleport
设计该Skill帮助开发者根据任务特性选择Claude Code的Web或CLI界面,并指导如何在两种环境间无缝迁移会话。它能分析任务复杂度、迭代需求等要素,推荐最优工作界面和工作流。关键特性包括会话状态管理、环境切换指导和上下文优化建议。
