技能创建器
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 快照 · 自动分类 · 以原作者文档为准
全配與板見 Extended Examples。
用 Optuna 或 Ray Tune 自超參優含 Hyperband、ASHA 之效搜策。
裝 Optuna 或 Ray Tune 含宜後端。
# 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
建項結構:
mkdir -p automl/{configs,experiments,models,results}
得:清境含諸需包裝、無依衝。
敗:用 Python 3.8-3.11(3.12+ 相容問題)、CUDA 誤先裝 CPU 唯本、M1/M2 Mac 用 conda 代 pip 為 scikit-learn。
建超參搜配。
# 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)
得:搜空覆合理超參範、旨函行無誤、剪止無望試早。
敗:試崩→縮搜空(如降最大 n_estimators)、驗資無 NaN/inf、察記憶(OOM 降批大)、確 eval_metric 合務型。
行超參搜含效採策。
# 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)
得:優成、50-70% 試早剪、最佳參得、收斂繪。
敗:無剪→驗旨報中值正、優不進→試異採(TPE → CmaES)、n_jobs > 1 崩→除錯用 n_jobs = 1。
Ray Tune 為多 GPU 或多節優。
# 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)
得:Ray Tune 跨 CPU/GPU 並試、ASHA 早止劣試、最佳配得錄。
敗:Ray 崩→除錯始 ray.init(num_cpus=2, num_gpus=0)、OOM 減並試、確訓函不改共資、用 tune.report() 非 return 為指。
接 MLflow 為驗追與模譜。
# 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)
得:諸試錄 MLflow 含參與指、最佳模註於 MLflow 譜、驗於 MLflow UI 可見。
敗:啟 MLflow UI mlflow ui --backend-store-uri file:./automl/mlruns、察 mlruns 寫權、註敗驗譜配、確模產 < 2GB。
存優模設察。
# automl/deploy_model.py
import joblib
import json
from pathlib import Path
import optuna
import xgboost as xgb
# ... (see EXAMPLES.md for complete implementation)
得:模存產備式、配文錄、推本建為釋。
敗:模檔太大(> 100MB)→考模壓或特選、驗模於新 Python 會載正、釋前測推本含樣資。
track-ml-experimentsorchestrate-ml-pipeline