mcframework.stats_engine.FnMetric#
- class mcframework.stats_engine.FnMetric[source]#
Bases:
Generic[_MetricT]Lightweight adapter that binds a human-readable
nameto a metric function.- Parameters:
- name
str Key under which the metric result is stored in
StatsEngine.compute().- fn
callable() Function with signature
fn(x: ndarray, ctx: StatsContext) -> T.- doc
str, optional Short description displayed by UIs or docs.
- name
Examples
>>> import numpy as np >>> m = FnMetric("mean", lambda a, ctx: float(np.mean(a))) >>> m(np.array([1, 2, 3]), StatsContext(n=3)) 2.0
Methods
- classmethod __new__(*args, **kwargs)#