storage.uniform_reservoir_storage#

This module contains the UniformReservoirStorage.

Classes

UniformReservoirStorage([size, store_targets])

Uniform Reservoir Storage

class storage.uniform_reservoir_storage.UniformReservoirStorage(size=1000, store_targets=False)[source]#

Bases: ReservoirStorage

Uniform Reservoir Storage

Summarizes a data stream by keeping track of a fixed length reservoir of observations. Each past observation of the stream has an equal probability of being in the reservoir at the current time. For more information we refer to https://en.wikipedia.org/wiki/Reservoir_sampling.

stored_samples int

Number of samples observed in the stream.

update(x, y=None)[source]#

Updates the reservoir with the current sample if necessary.

The update mechanism follows the optimal algorithm as stated here: https://en.wikipedia.org/wiki/Reservoir_sampling#Optimal:_Algorithm_L.

Parameters:
  • x (dict) – Current observation’s features.

  • y (Any, optional) – Current observation’s label. Defaults to None.