Parameters and metrics
Quick answer
Parameters configure computations; metrics describe measured outcomes. DVC can track selected parameter keys as granular dependencies and compare structured metric files between revisions. Examples use standard-library Python; native DVC commands are not executed. ByteMind execution is unverified.
Select a declared parameter subset
p={"train":{"alpha":2},"prepare":{"scale":4}}print(p["train"]["alpha"])Expected output (locally tested): 2. A stage can depend on one configuration key.
How it works
A params.yaml file might hold train.alpha and prepare.scale. In dvc.yaml the train stage declares train.alpha under params and its code reads that value. Changing a key should only invalidate stages that declare or indirectly consume its value. If the script reads the entire file, declaring only one key is unsafe unless other keys truly do not affect output. Store evaluation metrics as structured JSON with numeric values and explicit units and split names. DVC can compare metrics and parameters; this is not a substitute for selecting on validation data and freezing the evaluation protocol. Small metrics can be Git-tracked when configured without caching; this affects native run-cache behavior. The example template uses cached metrics to avoid that distinction. Never store credentials in parameter files or sensitive per-row predictions in metric outputs.
Compute an evaluation metric
from fractions import Fractiony=[1,4,8]; pred=[2,4,5]print(Fraction(sum(abs(a-b) for a,b in zip(y,pred)),len(y)))Expected output (locally tested): 4/3. MAE is a measured outcome rather than a parameter.
Common mistakes
Logging a parameter without declaring it as a dependency can produce stale models. Comparing a training metric to a test metric is misleading.
Practice and next steps
Change only a training parameter in the milestone; predict which stage executes and check the stage log. Explain why prepare should not rerun.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Parameters and metrics — knowledge check
Apply parameters and metrics to small examples and debugging scenarios.
Which is a parameter?
What is a granular dependency?
What if a consumed key is undeclared?
Which metric chooses a model?
What should not be logged?