MCPcopy Create free account
hub / github.com/geekcomputers/Python / get_average

Method get_average

ML/src/python/neuralforge/utils/metrics.py:36–44  ·  view source on GitHub ↗
(self, key: str, last_n: int = None)

Source from the content-addressed store, hash-verified

34 return self.best_metrics.get(key)
35
36 def get_average(self, key: str, last_n: int = None) -> float:
37 history = self.get_history(key)
38 if not history:
39 return 0.0
40
41 if last_n is not None:
42 history = history[-last_n:]
43
44 return np.mean([v for v in history if v is not None])
45
46 def save(self, filepath: str):
47 os.makedirs(os.path.dirname(filepath), exist_ok=True)

Callers

nothing calls this directly

Calls 1

get_historyMethod · 0.95

Tested by

no test coverage detected