Machine Learning के लिए CI/CD
Ravi Bhadauria
Machine Learning Engineer
outs से बदलेंstages:
preprocess:
...
train:
...
outs:
- metrics.json
- confusion_matrix.png
metrics मेंstages: preprocess: ... train: ... outs: - confusion_matrix.pngmetrics: - metrics.json: cache: false
-> dvc metrics showPath accuracy f1_score precision recall metrics.json 0.947 0.8656 0.988 0.7702
एक हाइपरपैरामीटर बदलें और dvc repro फिर चलाएँ
-> dvc metrics diffPath 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
setup-dvc GitHub Action जोड़ेंsteps: ... - name: Setup DVC uses: iterative/setup-dvc@v1- name: Run DVC pipeline run: dvc repro
- name: Write CML report env: REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | # वर्तमान ब्रांच की मैट्रिक प्रिंट करें dvc metrics show --md >> report.md# main ब्रांच से मैट्रिक तुलना करें git fetch --prune dvc metrics diff --md main >> report.md# CML रिपोर्ट बनाएँ cml comment create report.md

scatter - स्कैटर प्लॉटlinear - इंटरएक्टिव लीनियर प्लॉटsimple - नॉन-इंटरएक्टिव कस्टमाइज़ेबल लीनियर प्लॉटsmooth - स्मूदिंग वाला लीनियर प्लॉटconfusion - कन्फ्यूज़न मैट्रिक्सconfusion_normalized - मानों को <0, 1> रेंज में नॉर्मलाइज़ किया हुआ कन्फ्यूज़न मैट्रिक्सbar_horizontal - हॉरिज़ॉन्टल बार प्लॉटbar_horizontal_sorted - बार साइज के अनुसार सॉर्ट किया हुआ हॉरिज़ॉन्टल बार प्लॉटstages: train: ... 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 matrixcache: false # Git में सेव करें
-> dvc plots show predictions.csv
file:///path/to/index.html

-> dvc plots diff --target predictions.csv main
file:///path/to/index.html

# Python में बदलाव
y_proba = model.predict_proba(X_test)
fpr, tpr, _ = roc_curve(y_test,
y_proba[:, 1])
# dvc.yaml में बदलाव
plots:
- roc_curve.csv:
template: simple
x: fpr
y: tpr
x_label: 'False Positive Rate'
y_label: 'True Positive Rate'
title: ROC curve
cache: false

Machine Learning के लिए CI/CD