ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
registry.py
Go to the documentation of this file.
1from .categorical_accuracy import CategoricalAccuracy
2
3
5 """
6 Registry for creating metrics by name.
7 """
8 _metrics = {
9 "categorical_accuracy": CategoricalAccuracy,
10 }
11
12 @staticmethod
13 def create_metric(name):
14 """
15 Create a metric instance by name.
16 Args:
17 name (str): Name of the metric.
18 Returns:
19 BaseMetric: Metric instance.
20 """
21 if name not in MetricsRegistry._metrics:
22 raise ValueError(
23 f"Unknown Metric: {name}. Custom metric is not supported yet")
24 return MetricsRegistry._metrics[name]()