MCPcopy Create free account
hub / github.com/FastMAS/KVCOMM / Accuracy

Class Accuracy

experiments/accuracy.py:3–20  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1from KVCOMM.utils.log import logger
2
3class Accuracy:
4 def __init__(self):
5 self._num_correct = 0
6 self._num_total = 0
7
8 def update(self, predicted: str, target: str) -> None:
9 is_correct = target in predicted
10 self._num_correct += int(is_correct)
11 self._num_total += 1
12
13 def get(self) -> float:
14 return self._num_correct / self._num_total
15
16 def print(self):
17 accuracy = self.get()
18 logger.opt(colors=True).info(
19 f"<blue>[ACCURACY]</blue> {accuracy:%} ({self._num_correct}/{self._num_total})"
20 )

Callers 1

evaluateFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected