Communitygithub.com

DVC(データバージョン管理)

MLプロジェクト向けのデータバージョン管理。Gitと連携して大規模データセットやモデルを追跡し、再現可能なMLパイプラインを構築、メトリクス比較を伴う実験を実行します。S3、GCS、Azure、ローカルファイルシステムなど、あらゆるストレージバックエンドで動作します。

DVC(データバージョン管理) とは?

DVC(Data Version Control)は、機械学習プロジェクト向けのデータバージョン管理ツールです。Gitのバージョン管理機能を拡張し、大規模なデータセットやモデルファイルを効率的に追跡できるようにします。DVCを使うことで、データパイプラインの再現性を確保しながら、実験結果の比較やパラメータの管理を容易に行えます。S3、GCS、Azureなどの主要なクラウドストレージを含むあらゆるリモートストレージをサポートし、データはGitリポジトリ外のストレージに保管され、.dvcファイルで参照されます。パイプラインの各ステージはdvc.yamlで定義され、`dvc repro`コマンドで依存関係が変更されたステージのみを再実行します。実験管理機能`dvc exp`を使えば、ブランチを作成せずにパラメータ変更を試行し、メトリクスを比較できます。これにより、チームでの共同作業や実験の追跡が大幅に効率化されます。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/TerminalSkills/skills/tree/HEAD/skills/dvc

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

DVC(データバージョン管理) は何をしますか?

インストール

# クラウドストレージサポート付きで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 "トレーニングデータを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: パイプラインを再現 — 依存関係が変更されたステージのみ再実行します。
  • 実験: ブランチ不要の実験追跡 — 実行、比較、結果の適用が可能です。
  • パラメータ: 再現可能な設定のためにDVCで追跡されるYAMLパラメータファイル。
  • メトリクス: ビルトインの比較ツールを備えたJSON/YAMLメトリクスファイル。
  • リモートストレージ: S3、GCS、Azure、SSH、HDFS — データは任意の場所に保管できます。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

TerminalSkills/skills

>- Run GitHub Actions locally with act. Use when a user asks to test GitHub Actions workflows locally, debug CI pipelines without pushing, or run workflows offline.

TerminalSkills/skills

>- You are an expert in AG2 (formerly AutoGen), the open-source multi-agent conversation framework. You help developers build systems where multiple AI agents collaborate through structured conversations — with tool use, human-in-the-loop, code execution, group chat orchestration, and nested conversations — for complex tasks like software development, research, and data analysis.

TerminalSkills/skills

>- Generate short-form videos with AI — script writing, text-to-speech narration, stock footage selection, subtitle generation, and video assembly. Use when: creating TikTok/YouTube Shorts/Reels content, automating video production, building content pipelines.

TerminalSkills/skills

>- Animate 3D objects and characters in Blender with Python. Use when the user wants to keyframe properties, create armatures and rigs, set up IK/FK chains, animate shape keys for facial animation, edit F-Curves, use the NLA editor to blend actions, add drivers for expression-based animation, or script any animation workflow in Blender.

TerminalSkills/skills

>- Automate motion capture and tracking workflows in Blender with Python. Use when the user wants to import BVH or FBX mocap data, retarget motion to armatures, track camera or object motion from video, solve camera motion, clean up motion capture data, or script any tracking pipeline in Blender.

TerminalSkills/skills

>- You are an expert in Bolt.new by StackBlitz, the AI-powered full-stack development environment that runs entirely in the browser. You help developers go from idea to deployed app in minutes using natural language prompts — Bolt generates complete applications with frontend, backend, database, and deployment, all running in a WebContainer without local setup.

TerminalSkills/skills

>- Assists with using Bun as an all-in-one JavaScript/TypeScript runtime, package manager, bundler, and test runner. Use when building HTTP servers, managing packages, running tests, or migrating from Node.js. Trigger words: bun, bun serve, bun install, bun test, bun build, javascript runtime, bun runtime.

TerminalSkills/skills

>- Self-host customer support with Chatwoot. Use when a user asks to set up open-source customer support, add live chat without SaaS costs, build a multi-channel inbox, or deploy a free Intercom alternative.

TerminalSkills/skills

>- You are an expert in Chi, the lightweight, idiomatic Go HTTP router built on `net/http`. You help developers build composable HTTP services using Chi's middleware stack, route groups, URL parameters, sub-routers, and context-based request scoping — providing Express-like ergonomics while staying 100% compatible with Go's standard library.

TerminalSkills/skills

When the user wants to edit, review, or improve existing marketing copy. Also use when the user mentions 'edit this copy,' 'review my copy,' 'copy feedback,' 'proofread,' 'polish this,' 'make this better,' or 'copy sweep.' This skill provides a systematic approach to editing marketing copy through multiple focused passes.

TerminalSkills/skills

>- Add live chat and customer support with Crisp. Use when a user asks to add a chat widget, implement live customer support, set up a help desk, create a knowledge base, or add a chatbot to a website.

TerminalSkills/skills

>- Assists with building custom interactive data visualizations using D3.js. Use when creating charts, graphs, maps, force layouts, or hierarchical diagrams that require fine-grained control beyond what charting libraries provide. Trigger words: d3, data visualization, chart, svg, scales, force graph, treemap, choropleth.

TerminalSkills/skills

dbt (data build tool) transforms data in your warehouse using SQL SELECT statements. Learn project setup, models, tests, documentation, incremental materializations, and integration with data warehouses like PostgreSQL, BigQuery, and Snowflake.

TerminalSkills/skills

>- You are an expert in dlt, the open-source Python library for building data pipelines. You help developers load data from any API, file, or database into warehouses and lakes using simple Python decorators — with automatic schema inference, incremental loading, and built-in data contracts. dlt is the "requests library for data pipelines.

TerminalSkills/skills

>- You are an expert in E2B, the cloud platform for running AI-generated code in secure sandboxes. You help developers give AI agents the ability to execute code, install packages, read/write files, and run long processes in isolated cloud environments — each sandbox is a lightweight VM that boots in ~150ms with full Linux, filesystem, and networking.

TerminalSkills/skills

>- Transcode, convert, edit, and process audio and video with FFmpeg. Use when a user asks to convert video formats (webm to mp4, mkv to mp4), extract audio from video, compress video files, trim or cut clips, concatenate videos, add subtitles, create thumbnails, apply filters, change resolution or bitrate, re-encode media, create GIFs from video, add watermarks, normalize audio, stream media, or build automated media processing pipelines.

TerminalSkills/skills

>- Create advanced animations with GSAP. Use when building complex timelines, scroll-driven animations, SVG morphing, text animations, or high-performance web animations beyond CSS capabilities.

TerminalSkills/skills

>- Generate deterministic MP4 videos from HTML, CSS, media, and seekable animations using HeyGen's HyperFrames framework. Use when someone asks to "render HTML to video", "make a video with HyperFrames", "create a programmatic video", "turn an animation into MP4", "build a launch/product video from HTML", "render GSAP/Lottie/Three.js to video", or set up an agent-driven video pipeline. Covers init/preview/render/add/lint/inspect commands, data-* timing attributes, animation adapters, and the component catalog.

TerminalSkills/skills

When the user wants to perform load testing, stress testing, or performance testing of APIs and websites using k6. Also use when the user mentions "k6," "load test," "performance test," "stress test," "spike test," "soak test," "thresholds," "virtual users," or "VUs." For browser-based testing, see selenium.

TerminalSkills/skills

>- Lovable (formerly GPT Engineer) is a browser-based AI app builder that turns a natural-language description into a working full-stack web app with a built-in backend, authentication, database and one-click publishing. Use when the user wants to prototype or ship a web app with Lovable, write effective Lovable prompts, connect Supabase or GitHub, review generated security rules, or move a Lovable project into their own editor.

関連スキル