jpskill.com
🛠️ 開発・MCP コミュニティ

dvc

機械学習プロジェクトにおけるデータやモデルのバージョン管理をGitと連携して行い、実験の再現性を高め、S3などの様々なストレージに対応しながらメトリクス比較による実験管理を効率化するSkill。

📜 元の英語説明(参考)

Data Version Control for ML projects. Track large datasets and models alongside Git, build reproducible ML pipelines, and run experiments with metric comparison. Works with any storage backend including S3, GCS, Azure, and local filesystems.

🇯🇵 日本人クリエイター向け解説

一言でいうと

機械学習プロジェクトにおけるデータやモデルのバージョン管理をGitと連携して行い、実験の再現性を高め、S3などの様々なストレージに対応しながらメトリクス比較による実験管理を効率化するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o dvc.zip https://jpskill.com/download/14854.zip && unzip -o dvc.zip && rm dvc.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/14854.zip -OutFile "$d\dvc.zip"; Expand-Archive "$d\dvc.zip" -DestinationPath $d -Force; ri "$d\dvc.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して dvc.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → dvc フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

DVC (Data Version Control)

インストール

# クラウドストレージのサポート付きで DVC をインストール
pip install dvc[s3]    # AWS S3 用
pip install dvc[gs]    # Google Cloud Storage 用
pip install dvc[azure] # Azure Blob Storage 用
pip install dvc[all]   # 全てのリモート

# Git リポジトリで DVC を初期化
cd my-ml-project
git init
dvc init

データファイルの追跡

# track_data.sh — Git の代わりに DVC で大きなファイルを追跡
# 大きなデータセットを追加
dvc add data/training_images/
dvc add data/dataset.csv

# DVC は .dvc ファイル (小さなポインタ) を作成します — これらを Git にコミット
git add data/training_images.dvc data/dataset.csv.dvc .gitignore
git commit -m "Track training data with DVC"

リモートストレージの設定

# setup_remote.sh — DVC が実際のファイルコンテンツを保存する場所を設定
# S3
dvc remote add -d myremote s3://my-bucket/dvc-storage

# Google Cloud Storage
dvc remote add -d myremote gs://my-bucket/dvc-storage

# ローカル / ネットワークパス
dvc remote add -d myremote /mnt/shared/dvc-storage

# リモートにデータをプッシュ
dvc push

# リモートからデータをプル (別のマシン上またはクローン後)
dvc pull

再現可能なパイプラインの構築

# dvc.yaml — 依存関係と出力を持つ ML パイプラインのステージを定義
stages:
  prepare:
    cmd: python src/prepare.py
    deps:
      - src/prepare.py
      - data/raw/
    outs:
      - data/processed/

  train:
    cmd: python src/train.py
    deps:
      - src/train.py
      - data/processed/
    params:
      - train.epochs
      - train.learning_rate
      - train.batch_size
    outs:
      - models/model.pkl
    metrics:
      - metrics/train.json:
          cache: false

  evaluate:
    cmd: python src/evaluate.py
    deps:
      - src/evaluate.py
      - models/model.pkl
      - data/processed/
    metrics:
      - metrics/eval.json:
          cache: false
    plots:
      - metrics/confusion_matrix.csv:
          x: predicted
          y: actual
# params.yaml — パイプラインパラメータ (DVC で追跡)
train:
  epochs: 50
  learning_rate: 0.001
  batch_size: 32
# パイプライン全体を実行 (変更されたステージのみ再実行)
dvc repro

# 特定のステージを実行
dvc repro train

実験の追跡

# experiments.sh — ML 実験の実行と比較
# 変更されたパラメータで実験を実行
dvc exp run --set-param train.learning_rate=0.01

# 複数の実験を並行して実行
dvc exp run --set-param train.learning_rate=0.001 --queue
dvc exp run --set-param train.learning_rate=0.01 --queue
dvc exp run --set-param train.learning_rate=0.1 --queue
dvc queue start --jobs 3

# 実験を比較
dvc exp show
dvc exp diff

# 成功した実験をワークスペースに適用
dvc exp apply exp-abc123

# 実験を Git ブランチにプッシュ
dvc exp push origin exp-abc123

メトリクスとプロット

# train.py — DVC で追跡されるメトリクスを出力するトレーニングスクリプト
import json
from sklearn.ensemble import RandomForestClassifier
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score, f1_score
import yaml
import pickle

# パラメータをロード
with open("params.yaml") as f:
    params = yaml.safe_load(f)["train"]

X, y = load_iris(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

model = RandomForestClassifier(n_estimators=params["epochs"])
model.fit(X_train, y_train)

preds = model.predict(X_test)
metrics = {
    "accuracy": accuracy_score(y_test, preds),
    "f1_score": f1_score(y_test, preds, average="weighted"),
}

with open("metrics/train.json", "w") as f:
    json.dump(metrics, f, indent=2)

with open("models/model.pkl", "wb") as f:
    pickle.dump(model, f)
# 実験全体のメトリクスを表示
dvc metrics show
dvc metrics diff

# プロットを生成
dvc plots show metrics/confusion_matrix.csv
dvc plots diff  # 実験間のプロットを比較

クローンなしのデータアクセス

# フルクローンなしで、任意の DVC リポジトリから追跡されたファイルにアクセス
dvc get https://github.com/org/ml-repo data/processed/dataset.csv
dvc import https://github.com/org/ml-repo models/model.pkl
# dvc_api.py — プログラムで DVC で追跡されたファイルにアクセス
import dvc.api

# DVC リポジトリからファイルを読み込む
with dvc.api.open("data/dataset.csv", repo="https://github.com/org/ml-repo") as f:
    import pandas as pd
    df = pd.read_csv(f)

# 追跡されたファイルの URL を取得
url = dvc.api.get_url("models/model.pkl", repo="https://github.com/org/ml-repo")

主要な概念

  • .dvc ファイル: リモートストレージ内の大きなデータを参照する、Git にコミットされる小さなポインタファイル
  • dvc repro: パイプラインを再現 — 変更された依存関係を持つステージのみ再実行
  • 実験: ブランチフリーの実験追跡 — 結果の実行、比較、適用
  • Params: 再現可能な構成のために DVC で追跡される YAML パラメータファイル
  • Metrics: 組み込みの比較ツールを備えた JSON/YAML メトリクスファイル
  • Remote storage: S3, GCS, Azure, SSH, HDFS — データは必要な場所に保持
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

DVC (Data Version Control)

Installation

# Install DVC with cloud storage support
pip install dvc[s3]    # For AWS S3
pip install dvc[gs]    # For Google Cloud Storage
pip install dvc[azure] # For Azure Blob Storage
pip install dvc[all]   # All remotes

# Initialize DVC in a Git repo
cd my-ml-project
git init
dvc init

Track Data Files

# track_data.sh — Add large files to DVC tracking instead of Git
# Add a large dataset
dvc add data/training_images/
dvc add data/dataset.csv

# DVC creates .dvc files (small pointers) — commit those to Git
git add data/training_images.dvc data/dataset.csv.dvc .gitignore
git commit -m "Track training data with DVC"

Configure Remote Storage

# setup_remote.sh — Configure where DVC stores actual file contents
# S3
dvc remote add -d myremote s3://my-bucket/dvc-storage

# Google Cloud Storage
dvc remote add -d myremote gs://my-bucket/dvc-storage

# Local / network path
dvc remote add -d myremote /mnt/shared/dvc-storage

# Push data to remote
dvc push

# Pull data from remote (on another machine or after cloning)
dvc pull

Build Reproducible Pipelines

# dvc.yaml — Define ML pipeline stages with dependencies and outputs
stages:
  prepare:
    cmd: python src/prepare.py
    deps:
      - src/prepare.py
      - data/raw/
    outs:
      - data/processed/

  train:
    cmd: python src/train.py
    deps:
      - src/train.py
      - data/processed/
    params:
      - train.epochs
      - train.learning_rate
      - train.batch_size
    outs:
      - models/model.pkl
    metrics:
      - metrics/train.json:
          cache: false

  evaluate:
    cmd: python src/evaluate.py
    deps:
      - src/evaluate.py
      - models/model.pkl
      - data/processed/
    metrics:
      - metrics/eval.json:
          cache: false
    plots:
      - metrics/confusion_matrix.csv:
          x: predicted
          y: actual
# params.yaml — Pipeline parameters (tracked by DVC)
train:
  epochs: 50
  learning_rate: 0.001
  batch_size: 32
# Run the entire pipeline (only re-runs changed stages)
dvc repro

# Run a specific stage
dvc repro train

Experiment Tracking

# experiments.sh — Run and compare ML experiments
# Run an experiment with modified parameters
dvc exp run --set-param train.learning_rate=0.01

# Run multiple experiments in parallel
dvc exp run --set-param train.learning_rate=0.001 --queue
dvc exp run --set-param train.learning_rate=0.01 --queue
dvc exp run --set-param train.learning_rate=0.1 --queue
dvc queue start --jobs 3

# Compare experiments
dvc exp show
dvc exp diff

# Apply a successful experiment to workspace
dvc exp apply exp-abc123

# Push experiment to Git branch
dvc exp push origin exp-abc123

Metrics and Plots

# train.py — Training script that outputs DVC-tracked metrics
import json
from sklearn.ensemble import RandomForestClassifier
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score, f1_score
import yaml
import pickle

# Load params
with open("params.yaml") as f:
    params = yaml.safe_load(f)["train"]

X, y = load_iris(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

model = RandomForestClassifier(n_estimators=params["epochs"])
model.fit(X_train, y_train)

preds = model.predict(X_test)
metrics = {
    "accuracy": accuracy_score(y_test, preds),
    "f1_score": f1_score(y_test, preds, average="weighted"),
}

with open("metrics/train.json", "w") as f:
    json.dump(metrics, f, indent=2)

with open("models/model.pkl", "wb") as f:
    pickle.dump(model, f)
# View metrics across experiments
dvc metrics show
dvc metrics diff

# Generate plots
dvc plots show metrics/confusion_matrix.csv
dvc plots diff  # Compare plots between experiments

Data Access Without Cloning

# Access tracked files from any DVC repo without full clone
dvc get https://github.com/org/ml-repo data/processed/dataset.csv
dvc import https://github.com/org/ml-repo models/model.pkl
# dvc_api.py — Access DVC-tracked files programmatically
import dvc.api

# Read a file from a DVC repo
with dvc.api.open("data/dataset.csv", repo="https://github.com/org/ml-repo") as f:
    import pandas as pd
    df = pd.read_csv(f)

# Get the URL of a tracked file
url = dvc.api.get_url("models/model.pkl", repo="https://github.com/org/ml-repo")

Key Concepts

  • .dvc files: Small pointer files committed to Git that reference large data in remote storage
  • dvc repro: Reproduce pipelines — only re-runs stages with changed dependencies
  • Experiments: Branch-free experiment tracking — run, compare, and apply results
  • Params: YAML parameter files tracked by DVC for reproducible configurations
  • Metrics: JSON/YAML metrics files with built-in comparison tools
  • Remote storage: S3, GCS, Azure, SSH, HDFS — data stays where you want it