技能创建器
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 自動化超參之優與模擇,附效之搜策。
裝 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)
得:搜空覆合理之超參範,目函行而無誤,剪止無望之試於早。
敗則:試崩,縮搜空(如降 max 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 --backend-store-uri file:./automl/mlruns 啟 MLflow UI;察 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-experiments — MLflow 試跟與版orchestrate-ml-pipeline — Airflow/Kubeflow 為生產 AutoML 管線