MCPcopy Index your code
hub / github.com/DeepLabCut/DeepLabCut / evaluate

Method evaluate

deeplabcut/benchmark/base.py:76–110  ·  view source on GitHub ↗

Evaluate this benchmark with all registered methods.

(self, name: str, on_error="raise")

Source from the content-addressed store, hash-verified

74 )
75
76 def evaluate(self, name: str, on_error="raise"):
77 """Evaluate this benchmark with all registered methods."""
78
79 if name not in self.names():
80 raise ValueError(f"{name} is not registered. Valid names are {self.names()}")
81 if on_error not in ("ignore", "return", "raise"):
82 raise ValueError(f"on_error got an undefined value: {on_error}")
83 mean_avg_precision = float("nan")
84 root_mean_squared_error = float("nan")
85 try:
86 predictions = self.get_predictions(name)
87 predictions = self._validate_predictions(name, predictions)
88 mean_avg_precision = self.compute_pose_map(predictions)
89 root_mean_squared_error = self.compute_pose_rmse(predictions)
90 except Exception as exception:
91 if on_error == "ignore":
92 # ignore the exception and continue with the next evaluation, without
93 # yielding a result value.
94 return
95 elif on_error == "return":
96 # return the result value, with NaN as the result for all metrics that
97 # could not be computed due to the error.
98 pass
99 elif on_error == "raise":
100 # raise the error and stop evaluation
101 raise BenchmarkEvaluationError(f"Error during benchmark evaluation for model {name}") from exception
102 else:
103 raise NotImplementedError() from exception
104 return Result(
105 code=self.code,
106 method_name=name,
107 benchmark_name=self.name,
108 mean_avg_precision=mean_avg_precision,
109 root_mean_squared_error=root_mean_squared_error,
110 )
111
112 def _validate_predictions(self, name: str, predictions: dict) -> dict:
113 """Validates the submitted predictions object Checks that there is a prediction

Callers 10

compute_bbox_metricsFunction · 0.80
mainFunction · 0.80
evaluateFunction · 0.80
test_evaluate_basicFunction · 0.80
eval_cocoFunction · 0.80
eval_cocoFunction · 0.80

Calls 7

namesMethod · 0.95
get_predictionsMethod · 0.95
_validate_predictionsMethod · 0.95
compute_pose_mapMethod · 0.95
compute_pose_rmseMethod · 0.95
ResultClass · 0.85

Tested by 7

test_evaluate_basicFunction · 0.64
eval_cocoFunction · 0.64
eval_cocoFunction · 0.64