Skip to main content

Working with model metrics

It's often useful to store metadata about the model with the model artifact. This metadata might be output evaluations, like precision or recall, or input parameters like tree count and depth. Modelbit's name for all of this metadata is "metrics".

To store metrics with your model, supply the metrics= argument in mb.add_model or mb.add_models. You can add metrics after adding your model with mb.add_metrics.

You can later retrieve your model's metrics for analysis, comparison, plotting, etc. with mb.get_metrics.

Storing and fetching a model's metrics‚Äč

Here's an example storing a model's precision and recall metrics with the model and later retrieving them for comparison.

Storing metrics with the model:

mb.add_model("my_model", model_object, metrics={"precision": 0.8, "recall": 0.9})

Fetching metrics for comparison and analysis:

mb.get_metrics("my_model")
# returns {"precision": 0.8, "recall": 0.9})