aggregation
- class RelativeFrequencyCounter[source]
Bases:
sensai.util.string.ToStringMixin
Counts the absolute and relative frequency of an event
- __init__()
- count(is_relevant_event) None
Adds to the count. The nominator is incremented only if we are counting a relevant event. The denominator is always incremented.
- Parameters
is_relevant_event – whether we are counting a relevant event
- add(relative_frequency_counter: sensai.util.aggregation.RelativeFrequencyCounter) None
Adds the counts of the given counter to this object
- Parameters
relative_frequency_counter – the counter whose data to add
- get_relative_frequency() Optional[float]
- Returns
the relative frequency (between 0 and 1) or None if nothing was counted (0 events considered)
- class DistributionCounter[source]
Bases:
sensai.util.string.ToStringMixin
Supports the counting of the frequencies with which (mutually exclusive) events occur
- __init__()
- count(event: Hashable) None
Increments the count of the given event
- Parameters
event – the event/key whose count to increment, which must be hashable
- get_distribution() Dict[Hashable, float]
- Returns
a dictionary mapping events (as previously passed to count) to their relative frequencies
- class WeightedMean[source]
Bases:
sensai.util.string.ToStringMixin
Computes a weighted mean of values
- __init__()
- add(value, weight=1) None
Adds the given value with the given weight to the calculation
- Parameters
value – the value
weight – the weight with which to consider the value
- get_weighted_mean()
- Returns
the weighted mean of all values that have been added