跟踪从数据到模型的谱系
将已部署模型追溯到确切的数据和代码
跟踪从数据到模型的谱系 是 CoddyKit 上的免费 MLOps Academy 课时。 这是第 1 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 MLOps Academy 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 MLOps Academy 课程共包含 4 节课。
本课时的部分内容尚未翻译,以英文显示。
What Lineage Means
Lineage is the documented chain that links a deployed model back to the exact data, code, and config that produced it. 🔗
Why You Need It
When a prediction is questioned, lineage lets you answer one hard question: which data and which code version created this model?
The Three Inputs to Track
Every trained model has three parents worth tracking: the dataset version, the training code commit, and the run parameters.
Pin the Code Commit
Log the exact Git commit hash with each run so you always know which code trained the model.
import subprocess
commit = subprocess.check_output(["git", "rev-parse", "HEAD"]).decode().strip()
mlflow.set_tag("git_commit", commit)Pin the Data Version
Record the data version too. With DVC, the data hash lives in Git, so the commit already points to one exact dataset state.
MLflow Stores the Link
MLflow saves params, metrics, and tags per run, so a logged model already carries pointers to how it was built. 🧾
mlflow.log_param("data_path", "data/train.csv")
mlflow.log_metric("f1", 0.91)
mlflow.sklearn.log_model(model, "model")Tag the Run Generously
Tags are free metadata. Attach the dataset hash, environment name, and author so the run tells its own story later.
mlflow.set_tag("dataset_hash", "a1b2c3")
mlflow.set_tag("author", "team-fraud")Lineage Is a Graph
Picture lineage as a graph: data nodes flow into a training run, which flows into a model, which flows into a deployment.
Trace Forward and Backward
Good lineage works both ways. Backward answers what built this model; forward answers which models a dataset affected.
Read Lineage From a Run
You can fetch a past run by id and read its tags to reconstruct exactly which data and commit produced that model.
run = mlflow.get_run(run_id)
print(run.data.tags["git_commit"])
print(run.data.tags["dataset_hash"])Tools That Do This
MLflow, DVC, and dedicated tools like OpenLineage capture these links automatically so you do not stitch lineage together by hand.
Quick Check
Test your grasp of what lineage actually links together.
Recap
You learned that lineage ties a model to its data, code, and params, captured as tags on a run so any model is fully traceable. ✅
常见问题解答
「跟踪从数据到模型的谱系」课时是免费的吗?
是的 — 「跟踪从数据到模型的谱系」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 MLOps Academy 课程的其余内容,请升级到 CoddyKit PRO。 MLOps Academy 课程共包含 4 节课。
「跟踪从数据到模型的谱系」这节课中我会学到什么?
将已部署模型追溯到确切的数据和代码 你通过在浏览器中直接运行的动手代码来练习 MLOps Academy,全天候 AI 导师会在你学习这节课的过程中回答你的问题。
学习 MLOps Academy 需要有经验吗?
无需任何先前经验。CoddyKit 上的 MLOps Academy 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 1 节课,共 4 节。
「跟踪从数据到模型的谱系」课时需要多长时间?
大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。
我能在这节 MLOps Academy 课中编写并运行代码吗?
能。每节 MLOps Academy 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。