Downsampling (Downsample)

Downsampling reduces the number of frames in an observation sequence according to a specified downsample factor and one of two methods: averaging and decimation.

This is an especially helpful preprocessing method for speeding up classification times.

API reference

class sequentia.preprocessing.Downsample(factor, method='decimate')[source]

Downsamples an observation sequence (or multiple sequences) by either:

  • Decimating the next \(n-1\) observations

  • Averaging the current observation with the next \(n-1\) observations

Parameters
factor: int > 0

Downsample factor.

method: {‘decimate’, ‘mean’}

The downsampling method.

Examples

>>> # Create some sample data
>>> X = [np.random.random((10 * i, 3)) for i in range(1, 4)]
>>> # Downsample the data with downsample factor 5 and decimation
>>> X = Downsample(factor=5, method='decimate')(X)
transform(x)[source]

Applies the transformation to a single observation sequence.

Parameters
X: numpy.ndarray (float)

An individual observation sequence.

Returns
transformed:class:numpy:numpy.ndarray (float)

The transformed input observation sequence.

__call__(X, validate=True)

Applies the transformation to the observation sequence(s).

Parameters
X: numpy.ndarray (float) or list of numpy.ndarray (float)

An individual observation sequence or a list of multiple observation sequences.

validate: bool

Whether or not to validate the input sequences.

Returns
transformed:class:numpy:numpy.ndarray (float) or list of numpy.ndarray (float)

The transformed input observation sequence(s).