技能创建器
skill-creator
创建、改进和评估自定义技能,把专业流程转化为可重复使用的 AI 能力。
setup-automl-pipeline【数据与研究】Configure automated machine learning pipelines using Optuna or Ray Tune for hyperparameter optimization. Implement efficient search strategies (Hyperband, ASHA), define search spaces, and set up early stopping to find optimal model configurations with minimal manual tuning. Use when starting a new ML project and needing to quickly find good configura…
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
See Extended Examples for complete configuration files and templates.
Automate hyperparameter tuning + model selection using Optuna or Ray Tune with efficient search strategies.
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
Make project structure.
mkdir -p automl/{configs,experiments,models,results}
Got: Clean env with required packages installed, no dep conflicts.
If fail: Use Python 3.8-3.11 (compat issues with 3.12+). CUDA errors? Install CPU-only versions first. M1/M2 Mac? Use conda not pip for scikit-learn.
Make config for hyperparam 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)
Got: Search space covers reasonable hyperparam ranges, objective runs without errors, pruning stops unpromising trials early.
If fail: Trials crash? Reduce search space (lower max n_estimators), verify data has no NaN/inf, check memory (reduce batch size if OOM), ensure eval_metric matches task type.
Execute hyperparam 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)
Got: Optimization completes with 50-70% trials pruned early, best params found, viz plots generated showing convergence.
If fail: No pruning? Verify objective reports intermediate values correct. Optimization not improving? Try different sampler (TPE → CmaES). Crashes with n_jobs>1? Use n_jobs=1 for debugging.
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)
Got: Ray Tune runs trials in parallel across CPUs/GPUs, ASHA scheduler stops bad trials early, best config found + logged.
If fail: Ray crashes? Start with ray.init(num_cpus=2, num_gpus=0) for debug, reduce concurrent trials if OOM, check train function does not modify shared data, use tune.report() not return for metrics.
Integrate with MLflow for experiment tracking + 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)
Got: All trials logged to MLflow with params + metrics, best model registered in MLflow registry, experiments viewable in MLflow UI.
If fail: Start MLflow UI with mlflow ui --backend-store-uri file:./automl/mlruns. Check write perms to mlruns dir. Registration fails? Verify model registry configured. Ensure model artifact <2GB.
Save optimized model + 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)
Got: Model saved in prod-ready format, config documented, inference script made for deployment.
If fail: Model file too large (>100MB)? Consider model compression or feature selection. Verify model loads correct in fresh Python session. Test inference script with sample data before deployment.
track-ml-experiments - MLflow experiment tracking + versioningorchestrate-ml-pipeline - Airflow/Kubeflow for production AutoML pipelines