Evaluasi: Metrik dan plot di DVC

Pengantar Versioning Data dengan DVC

Ravi Bhadauria

Machine Learning Engineer

Metrik: perubahan di dvc.yaml

  • Konfigurasi file YAML DVC untuk melacak metrik antar eksperimen
  • Ubah dari outs
stages:
  train_and_evaluate:
    outs:
    - metrics.json
    - plots.png

$$ $$

  • Ke metrics
stages:
  train_and_evaluate:
    outs:
    - plots.png
    metrics:
      - metrics.json:
        cache: false
Pengantar Versioning Data dengan DVC

Mencetak metrik DVC

$ dvc metrics show
Path          accuracy    f1_score    precision    recall             
metrics.json  0.947       0.8656      0.988        0.7702
Pengantar Versioning Data dengan DVC

Bandingkan metrik antar run

  • Ubah satu hiperparameter dan jalankan ulang 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
Pengantar Versioning Data dengan DVC

Plot: perubahan di dvc.yaml

stages:
  train_and_evaluate:
    ...
    plots:
    - predictions.csv: # Nama file berisi prediksi
        template: confusion # Gaya plot

x: predicted_label # Nama kolom sumbu X di file csv y: true_label # Nama kolom sumbu Y di file csv x_label: 'Predicted label' y_label: 'True label' title: Confusion matrix
cache: false # Simpan di Git
1 https://dvc.org/doc/user-guide/experiment-management/visualizing-plots#plot-templates-data-series-only
Pengantar Versioning Data dengan DVC

Mencetak plot DVC ke file

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

Plot tampilan confusion matrix yang dibuat DVC

Pengantar Versioning Data dengan DVC

Membandingkan plot DVC

# bandingkan plot di predictions.csv dengan branch main
$ dvc plots diff --target predictions.csv <branch name or commit SHA>

Plot perbandingan confusion matrix yang dibuat DVC

Pengantar Versioning Data dengan DVC

Ayo berlatih!

Pengantar Versioning Data dengan DVC

Preparing Video For Download...