utils.tracker#

This module gathers objects to keep track of incremental / sequential data

class utils.tracker.ExponentialSmoothingTracker(alpha)[source]#

Bases: Tracker

A Tracker that applies Exponential Smoothing on the numeric input values.

update(value_i)[source]#

Adds one value to the Tracker

Parameters:

value_i (int or float) – The numeric value to be added to the tracker.

Return type:

Tracker

class utils.tracker.MultiValueTracker(base_tracker)[source]#

Bases: Tracker

A Tracker for storing multiple values at once in the form of a dict mapping from keys to individual Trackers.

tracked_value#

The dictionary containing the individual trackers for each value.

Type:

dict

__call__()[source]#

Returns the current tracked values.

get()[source]#

Returns the current tracked values.

Return type:

dict

get_normalized()[source]#

Normalizes the tracked values by dividing them through the sum of the values.

update(values)[source]#

Adds one value for tracked object to the tracker.

Note

Whenever the input dictionary contains a new key not stored in the Tracker, it will be added to its storage.

Parameters:

values (dict) – A dictionary mapping from keys to numeric values to be added to the tracker.

Return type:

Tracker

class utils.tracker.SlidingWindowTracker(k)[source]#

Bases: Tracker

A sliding window tracker that stores the k last elements of the stream allowing for computation of the mean and variance of the last k values.

__call__(*args, **kwargs)[source]#

Returns the current mean of the sliding window.

update(value_i)[source]#

Adds one value to the Tracker

Parameters:

value_i (int or float) – The numeric value to be added to the tracker.

Return type:

Tracker

property mean#

Returns the current mean of the sliding window.

property std#

Returns the standard deviation of the sliding window.

property var#

Returns the variance of the sliding window.

class utils.tracker.WelfordTracker[source]#

Bases: Tracker

A Tracker that applies Welford’s Algorithm to estimate the mean and variance of a sequence.

Notes

Taken and adapted from Ian Covert’s SAGE implementation.

update(value_i)[source]#

Adds one value to the Tracker.

Parameters:

value_i (int or float) – The numeric value to be added to the tracker.

property mean#

Returns the mean of the stream.

property std#

Returns the standard deviation of the stream.

property var#

Returns the variance of the stream.

Modules