スキル一覧に戻る

track-ml-experiments

pjt222
更新日 Yesterday
19 閲覧
17
2
17
GitHubで表示
メタaiautomationdesign

について

このスキルは、自動ロギングとアーティファクト管理を備えたMLflowを自動実験トラッキング用に設定します。開発者がトレーニング実行を体系的に比較し、再現可能なMLワークフローを構築するのに役立ちます。トラッキングが必要なMLプロジェクトを開始する際や、手動ロギングからの移行時にご利用ください。

クイックインストール

Claude Code

推奨
メイン
npx skills add pjt222/agent-almanac -a claude-code
プラグインコマンド代替
/plugin add https://github.com/pjt222/agent-almanac
Git クローン代替
git clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/track-ml-experiments

このコマンドをClaude Codeにコピー&ペーストしてスキルをインストールします

ドキュメント

Track ML Experiments

See Extended Examples for complete configuration files and templates.

Set up MLflow tracking server and implement comprehensive experiment tracking with metrics, parameters, and artifacts.

适用场景

  • Starting a new machine learning project requiring experiment tracking
  • Migrating from manual experiment logs to automated tracking
  • Comparing multiple model training runs systematically
  • Sharing experiment results with team members
  • Building reproducible ML workflows with full lineage tracking
  • Integrating experiment tracking into CI/CD pipelines

输入

  • 必需: Python environment with ML framework (sklearn, pytorch, tensorflow, xgboost)
  • 必需: MLflow installation (pip install mlflow)
  • 可选: Remote storage backend (S3, Azure Blob, GCS) for artifacts
  • 可选: Database backend (PostgreSQL, MySQL) for metadata storage
  • 可选: Authentication credentials for remote backends

步骤

第 1 步:Initialize MLflow Tracking Server

Set up the MLflow tracking server with appropriate backend stores.

# Option 1: Local file-based tracking (development)
mkdir -p mlruns
export MLFLOW_TRACKING_URI="file:./mlruns"

# Option 2: SQLite backend with local artifacts
mlflow server \
  --backend-store-uri sqlite:///mlflow.db \
  --default-artifact-root ./mlartifacts \
# ... (see EXAMPLES.md for complete implementation)

Create a configuration file for team sharing:

# mlflow_config.py
import os

MLFLOW_TRACKING_URI = os.getenv(
    "MLFLOW_TRACKING_URI",
    "http://mlflow-server.company.com:5000"
)

# ... (see EXAMPLES.md for complete implementation)

预期结果: MLflow UI accessible at specified host:port, showing empty experiments list. Server logs confirm successful startup without errors.

失败处理: Check port availability with netstat -tulpn | grep 5000, verify database connection strings, ensure S3 credentials are configured (aws configure), check firewall rules for remote access.

第 2 步:Configure Autologging for ML Frameworks

Enable framework-specific autologging to capture metrics, parameters, and models automatically.

# training_script.py
import mlflow
from mlflow_config import MLFLOW_TRACKING_URI, MLFLOW_EXPERIMENT_NAME

# Set tracking URI
mlflow.set_tracking_uri(MLFLOW_TRACKING_URI)
mlflow.set_experiment(MLFLOW_EXPERIMENT_NAME)

# ... (see EXAMPLES.md for complete implementation)

For PyTorch:

import mlflow.pytorch

mlflow.pytorch.autolog(
    log_every_n_epoch=1,
    log_every_n_step=None,
    log_models=True,
    disable=False,
    exclusive=False,
# ... (see EXAMPLES.md for complete implementation)

预期结果: Run appears in MLflow UI with all hyperparameters, metrics (training/validation loss, accuracy), model artifacts, and input examples automatically logged.

失败处理: Verify MLflow version compatibility with ML framework (mlflow.sklearn.autolog() requires MLflow ≥1.20), check if autologging is supported for your model type, disable autologging and use manual logging as fallback, inspect logs with mlflow.set_tracking_uri() for connection errors.

第 3 步:Implement Comprehensive Manual Logging

Add custom metrics, parameters, artifacts, and tags for complete experiment documentation.

# comprehensive_tracking.py
import mlflow
import numpy as np
import matplotlib.pyplot as plt
from pathlib import Path

def train_and_log_model(params, X_train, y_train, X_test, y_test):
    """
# ... (see EXAMPLES.md for complete implementation)

预期结果: MLflow UI displays rich experiment information including step-by-step metrics, visualization artifacts, model signature, input examples, and comprehensive tags for filtering and searching.

失败处理: Check artifact storage permissions (aws s3 ls s3://bucket/path), verify matplotlib backend for figure logging (plt.switch_backend('Agg')), ensure JSON-serializable data types for log_dict, check disk space for local artifact storage.

第 4 步:Compare Runs and Generate Reports

Use MLflow's comparison tools to analyze multiple experiments.

# compare_runs.py
import mlflow
from mlflow.tracking import MlflowClient

client = MlflowClient()

def compare_experiments(experiment_name, metric_name="test_accuracy", top_n=5):
    """
# ... (see EXAMPLES.md for complete implementation)

Command-line comparison:

# Compare runs using MLflow CLI
mlflow runs compare --experiment-name customer-churn \
  --order-by "metrics.test_accuracy DESC" \
  --max-results 10

# Export run data to CSV
mlflow experiments csv --experiment-name customer-churn \
  --output experiments.csv

预期结果: Console output shows sorted runs with key metrics, HTML report generated with formatted comparison table, CSV file contains all run data for further analysis.

失败处理: Verify experiment exists with mlflow experiments list, check metric names match exactly (case-sensitive), ensure runs have completed successfully (check run status), verify file write permissions for output files.

第 5 步:Configure Remote Artifact Storage

Set up S3/Azure/GCS backends for scalable artifact management.

# artifact_storage_config.py
import mlflow
import os

def configure_s3_backend():
    """
    Configure S3 for artifact storage.
    """
# ... (see EXAMPLES.md for complete implementation)

Docker Compose for MLflow with PostgreSQL and S3:

# docker-compose.yml
version: '3.8'

services:
  postgres:
    image: postgres:14
    environment:
      POSTGRES_DB: mlflow
# ... (see EXAMPLES.md for complete implementation)

预期结果: Artifacts upload successfully to remote storage, MLflow UI shows artifact links pointing to S3/Azure/GCS URIs, downloading artifacts from UI works correctly.

失败处理: Verify cloud credentials with aws s3 ls or az storage blob list, check bucket/container permissions (need write access), ensure MLflow installed with cloud extras (pip install mlflow[extras]), test network connectivity to storage endpoints, check CORS settings for browser access.

第 6 步:Implement Experiment Lifecycle Management

Set up automated cleanup, archival, and organization policies.

# lifecycle_management.py
import mlflow
from mlflow.tracking import MlflowClient
from datetime import datetime, timedelta

client = MlflowClient()

def archive_old_experiments(days_old=90):
# ... (see EXAMPLES.md for complete implementation)

预期结果: Old experiments moved to deleted state, failed runs removed from active list, best runs tagged for easy filtering in UI, storage space reclaimed.

失败处理: Check experiment permissions (must be owner to delete), verify runs are actually in FAILED status, ensure metric exists for all runs being ranked, check database connectivity for bulk operations, verify sufficient permissions for artifact deletion in remote storage.

验证清单

  • MLflow tracking server accessible via web UI
  • Experiments created and runs logged successfully
  • Autologging captures framework-specific metrics automatically
  • Custom metrics, parameters, and artifacts logged correctly
  • Comparison queries return expected top runs
  • Remote artifact storage configured and functional
  • Artifacts downloadable from UI and programmatically
  • Run filtering and searching works with tags
  • HTML comparison reports generated without errors
  • Lifecycle management scripts execute successfully

常见问题

  • Connection timeouts: MLflow server not accessible from training scripts - verify MLFLOW_TRACKING_URI environment variable, check firewall rules, ensure server is running
  • Artifact upload failures: S3/Azure credentials not configured or bucket doesn't exist - test cloud CLI access first, verify bucket permissions
  • Missing metrics: Autologging disabled or unsupported framework version - check MLflow version compatibility, fall back to manual logging
  • Run clutter: Too many experimental runs polluting UI - implement tagging strategy early, use lifecycle management scripts regularly
  • Large artifacts: Logging entire datasets causes storage bloat - log only samples or references, use external data versioning (DVC)
  • Inconsistent naming: Parameters logged with different names across runs - standardize naming conventions in config file
  • Database locks: SQLite doesn't support concurrent writes - use PostgreSQL/MySQL for multi-user environments
  • Autolog conflicts: Multiple autolog configurations interfere - use exclusive=True or disable conflicting autologs

相关技能

  • register-ml-model - Register tracked models in MLflow Model Registry
  • version-ml-data - Version datasets using DVC for reproducible experiments
  • setup-automl-pipeline - Integrate experiment tracking into automated ML pipelines
  • deploy-ml-model-serving - Deploy best-performing tracked models to production
  • orchestrate-ml-pipeline - Combine experiment tracking with workflow orchestration

GitHub リポジトリ

pjt222/agent-almanac
パス: i18n/zh-CN/skills/track-ml-experiments
0
agentsagentskillsai-assisted-developmentclaude-codeskillsteams

関連スキル

content-collections

メタ

このスキルは、Content Collections(Markdown/MDXファイルを型安全なデータコレクションに変換するTypeScriptファーストのツール)の本番環境でテストされた設定を提供します。Zodバリデーションによる型安全性を実現し、ブログ、ドキュメントサイト、コンテンツ重視のVite + Reactアプリケーション構築時にご利用ください。Viteプラグインの設定、MDXコンパイルから、デプロイ最適化、スキーマバリデーションまで、すべてを網羅しています。

スキルを見る

polymarket

メタ

このスキルは、開発者がPolymarket予測市場プラットフォームを活用したアプリケーション構築を可能にします。API統合による取引や市場データの取得に加え、WebSocketを介したリアルタイムデータストリーミングにより、ライブ取引や市場活動を監視できます。取引戦略の実装や、ライブ市場更新を処理するツールの作成にご利用ください。

スキルを見る

creating-opencode-plugins

メタ

このスキルは、開発者がコマンド、ファイル、LSP操作など25種類以上のイベントタイプにフックするOpenCodeプラグインを作成することを支援します。JavaScript/TypeScriptモジュール向けに、プラグイン構造、イベントAPI仕様、および実装パターンを提供します。カスタムイベント駆動ロジックでOpenCode AIアシスタントのライフサイクルをインターセプト、監視、または拡張する必要がある場合にご利用ください。

スキルを見る

sglang

メタ

SGLangは、高性能なLLMサービングフレームワークであり、RadixAttentionプレフィックスキャッシュを活用したJSON、正規表現、エージェントワークフロー向けの高速で構造化された生成を特長とします。特にプレフィックスが繰り返されるタスクにおいて、大幅に高速な推論を実現し、複雑な構造化出力やマルチターン対話に最適です。制約付きデコードが必要な場合や、広範なプレフィックス共有を伴うアプリケーションを構築する場合は、vLLMなどの代替案ではなくSGLangを選択してください。

スキルを見る