lenskit.data.accum#
Data accumulation support
Classes#
Protocol implemented by data accumulators. |
|
Base class for protocol classes. |
|
An accumulator for single real values, computing basic statistics. |
|
Collected statitsics from |
Package Contents#
- class lenskit.data.accum.Accumulator[X, R]#
Bases:
ProtocolProtocol implemented by data accumulators.
- add(value)#
Add a single value to this accumulator.
- Parameters:
value (X)
- Return type:
None
- accumulate()#
Compute the accumulated value from this accumulator.
- Return type:
R
- class lenskit.data.accum.AccumulatorFactory[X, R]#
Bases:
ProtocolBase class for protocol classes.
Protocol classes are defined as:
class Proto(Protocol): def meth(self) -> int: ...
Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).
For example:
class C: def meth(self) -> int: return 0 def func(x: Proto) -> int: return x.meth() func(C()) # Passes static type check
See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:
class GenProto[T](Protocol): def meth(self) -> T: ...
- create_accumulator()#
Create an accumulator for the results of this object.
- Returns:
An accumulator.
- Return type:
Accumulator[X, R]
- class lenskit.data.accum.ValueStatAccumulator#
Bases:
lenskit.data.accum._proto.Accumulator[float | None,ValueStatistics]An accumulator for single real values, computing basic statistics.
- property values: numpy.ndarray[tuple[int], numpy.dtype[numpy.float64]]#
- Return type:
numpy.ndarray[tuple[int], numpy.dtype[numpy.float64]]
- accumulate()#
Compute the accumulated value from this accumulator.
- Return type: