-
Notifications
You must be signed in to change notification settings - Fork 0
Metrics_stories
US Metrics : Provide standardized measurements for model performance, accuracy, and evaluation
Provide standardized measurements for model performance, accuracy, and evaluation. Useful for tracking improvement and identifying bottlenecks.
classDiagram
%% Base Class: Metric
class Metric {
<<abstract>>
+KIND: str
+name: str
+greater_is_better: bool
+score(targets: schemas.Targets, outputs: schemas.Outputs) float*
+scorer(model: models.Model, inputs: schemas.Inputs, targets: schemas.Targets) float
+to_mlflow() MlflowMetric
}
Metric --|> pdt.BaseModel : inherits
Metric --|> abc.ABC : inherits
%% SklearnMetric Class
class SklearnMetric {
+KIND: T.Literal["SklearnMetric"]
+name: str = "mean_squared_error"
+greater_is_better: bool = False
+score(targets: schemas.Targets, outputs: schemas.Outputs) float
}
Metric <|-- SklearnMetric : specializes
%% Threshold Class
class Threshold {
+threshold: int | float
+greater_is_better: bool
+to_mlflow() MlflowThreshold
}
Threshold --|> pdt.BaseModel : inherits
Threshold --|> abc.ABC : inherits
%% Relationships
Metric ..> schemas.Targets : uses
Metric ..> schemas.Outputs : uses
Metric ..> models.Model : uses
Title:
As a machine learning engineer, I want a base Metric class to standardize the evaluation of model performance, so that I can consistently compute and report metrics across different models and use cases.
Description:
The Metric class serves as a base for implementing various evaluation metrics. It defines the core attributes and methods required for metric computation, ensures compatibility with mlflow, and facilitates seamless integration into machine learning pipelines using pydantic for validation.
Acceptance Criteria:
-
Attributes
- Define
KINDto identify the metric type. - Include
name(str) andgreater_is_better(bool).
- Define
-
Abstract Method:
score- Define
scoreto compute the metric value fromtargetsandoutputs.
- Define
-
Helper Method:
scorer- Implement
scorerto evaluate a model's predictions against targets using the metric.
- Implement
-
Integration with
mlflow:to_mlflow- Provide
to_mlflowto convert the metric into anmlflow.metrics.make_metricobject.
- Provide
-
Validation
- Use
pydantic.BaseModelwithstrict=True,frozen=True, andextra="forbid".
- Use
Definition of Done (DoD):
-
Metricclass implemented and tested. -
to_mlflowintegration verified. - Unit tests cover various metric scenarios.
Title:
As a data scientist, I want to use SklearnMetric to compute evaluation metrics using scikit-learn functions.
Description:
The SklearnMetric class extends Metric to utilize sklearn.metrics. It allows computing metrics based on the name attribute using getattr(metrics, self.name).
Acceptance Criteria:
-
Attributes
-
KINDset to"SklearnMetric". -
namedefaults to"mean_squared_error". -
greater_is_betterdefaults toFalse.
-
-
scoreMethod- Computes the metric value using
sklearn.metrics. - Adjusts the sign based on
greater_is_better.
- Computes the metric value using
Definition of Done (DoD):
-
SklearnMetricimplemented and tested with standard sklearn metrics.
Title:
As a machine learning engineer, I want to define a Threshold class for metrics to monitor performance and trigger alerts.
Description:
The Threshold class provides a way to define and manage thresholds, supporting integration with mlflow thresholds.
Acceptance Criteria:
-
Attributes
-
threshold(int | float). -
greater_is_better(bool).
-
-
Method:
to_mlflow- Converts to
mlflow.models.MetricThreshold.
- Converts to
Definition of Done (DoD):
-
Thresholdclass implemented andto_mlflowverified.
Powered by MLOps Factory