การจัดการเวอร์ชันข้อมูลด้วย DVC เบื้องต้น
Ravi Bhadauria
Machine Learning Engineer
ทำซ้ำได้ (Reproducible): สร้างผลลัพธ์เดิมได้ในสภาพแวดล้อมและเวลาที่ต่างกัน
เป็นโมดูล (Modular): เขียนเป็นโมดูลอิสระที่ทดสอบได้แยกกัน
สอดคล้องกัน (Consistent): มีแหล่งข้อมูลเดียวสำหรับพารามิเตอร์ทั้งหมด

ไฟล์ต้องอยู่ในรูปแบบที่รองรับ
params.yamlจะใช้งาน YAML ในบทนี้
.yaml หรือ .ymlกำหนดพารามิเตอร์เป็น dictionary
:คอมเมนต์เริ่มต้นด้วย #
ชนิดข้อมูล:
โครงสร้างข้อมูล:
การย่อหน้ามีความสำคัญ
# Key-value pairs
a: 1
b: 1.2
c: "String value"
# Arrays
a: [1, 2.2, 3, 4.8]
b:
- 5
- "String value"
# Nested dictionaries
a:
b: "Some value"
c: "Some other value"
# Data preprocessing paramters preprocess: ... target_column: RainTomorrow categorical_features: - Location - WindGustDir - ...# Model training/evaluation paramters train_and_evaluate: rfc_params: n_estimators: 2 ...
# In model.py
def evaluate_model(model, X_test, y_test):
"""Evaluate a model on a test set and return metrics."""
y_pred = model.predict(X_test)
precision = precision_score(y_test, y_pred)
...
return { "accuracy": accuracy, "precision": precision,
"recall": recall, "f1_score": f1 }
# In entry-point code (train_and_evaluate.py)
from model import evaluate_model
metrics = evaluate_model(model, X_test, y_test)

การจัดการเวอร์ชันข้อมูลด้วย DVC เบื้องต้น