MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / BinaryClassificationStats

Class BinaryClassificationStats

tensorpack/callbacks/inference.py:180–208  ·  view source on GitHub ↗

Compute precision / recall in binary classification, given the prediction vector and the label vector.

Source from the content-addressed store, hash-verified

178
179
180class BinaryClassificationStats(Inferencer):
181 """
182 Compute precision / recall in binary classification, given the
183 prediction vector and the label vector.
184 """
185
186 def __init__(self, pred_tensor_name, label_tensor_name, prefix='val'):
187 """
188 Args:
189 pred_tensor_name(str): name of the 0/1 prediction tensor.
190 label_tensor_name(str): name of the 0/1 label tensor.
191 """
192 self.pred_tensor_name = pred_tensor_name
193 self.label_tensor_name = label_tensor_name
194 self.prefix = prefix
195
196 def _before_inference(self):
197 self.stat = BinaryStatistics()
198
199 def _get_fetches(self):
200 return [self.pred_tensor_name, self.label_tensor_name]
201
202 def _on_fetches(self, outputs):
203 pred, label = outputs
204 self.stat.feed(pred, label)
205
206 def _after_inference(self):
207 return {self.prefix + '_precision': self.stat.precision,
208 self.prefix + '_recall': self.stat.recall}

Callers 1

get_configFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…