評価:DVCのメトリクスとプロット

DVCによるデータバージョニング入門

Ravi Bhadauria

Machine Learning Engineer

メトリクス:dvc.yamlの変更

  • 実験間でメトリクスを追跡するようDVCのYAMLを設定
  • outs から変更
stages:
  train_and_evaluate:
    outs:
    - metrics.json
    - plots.png

$$ $$

  • metrics
stages:
  train_and_evaluate:
    outs:
    - plots.png
    metrics:
      - metrics.json:
        cache: false
DVCによるデータバージョニング入門

DVCメトリクスの出力

$ dvc metrics show
Path          accuracy    f1_score    precision    recall             
metrics.json  0.947       0.8656      0.988        0.7702
DVCによるデータバージョニング入門

実行間でメトリクスを比較

  • ハイパーパラメータを変更し、dvc repro を再実行
$ dvc metrics diff
Path          Metric     HEAD    workspace    Change                  
metrics.json  accuracy   0.947   0.9995       0.0525
metrics.json  f1_score   0.8656  0.9989       0.1333
metrics.json  precision  0.988   0.9993       0.0113
metrics.json  recall     0.7702  0.9986       0.2284
DVCによるデータバージョニング入門

プロット:dvc.yamlの変更

stages:
  train_and_evaluate:
    ...
    plots:
    - predictions.csv: # 予測を含むファイル名
        template: confusion # プロットのスタイル

x: predicted_label # CSVのX軸列名 y: true_label # CSVのY軸列名 x_label: 'Predicted label' y_label: 'True label' title: Confusion matrix
cache: false # Gitに保存
1 https://dvc.org/doc/user-guide/experiment-management/visualizing-plots#plot-templates-data-series-only
DVCによるデータバージョニング入門

DVCプロットをファイルに出力

$ dvc plots show predictions.csv
file:///path/to/index.html

DVCで生成した混同行列プロット

DVCによるデータバージョニング入門

DVCプロットの比較

# predictions.csv のプロットをブランチ main と比較
$ dvc plots diff --target predictions.csv <branch name or commit SHA>

DVCで生成した混同行列の差分プロット

DVCによるデータバージョニング入門

演習に進みましょう!

DVCによるデータバージョニング入門

Preparing Video For Download...