Centering (center)

Centers an observation sequence about the mean of its observations – that is, given:

\[\begin{split}O=\begin{pmatrix} o_1^{(1)} & o_2^{(1)} & \cdots & o_D^{(1)} \\ o_1^{(2)} & o_2^{(2)} & \cdots & o_D^{(2)} \\ \vdots & \vdots & \ddots & \vdots \\ o_1^{(T)} & o_2^{(T)} & \cdots & o_D^{(T)} \end{pmatrix} \qquad \boldsymbol{\mu}=\begin{pmatrix} \overline{o_1} & \overline{o_2} & \cdots & \overline{o_D} \end{pmatrix}\end{split}\]

Where \(\overline{o_d}\) represents the mean of the \(d^\text{th}\) feature of \(O\).

We subtract \(\boldsymbol{\mu}\) from each observation, or row in \(O\). This centers the observations.

For further information, please see the preprocessing tutorial notebook.

Example

1
2
3
4
5
6
7
8
import numpy as np
from sequentia.preprocessing import center

# Create some sample data
X = [np.random.random((10 * i, 3)) for i in range(1, 4)]

# Center the data
X = center(X)

API reference

sequentia.preprocessing.center(X)[source]

Centers an observation sequence (or multiple sequences) by centering observations around the mean.

Parameters:
X: numpy.ndarray or List[numpy.ndarray]

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

Returns:
centered: numpy.ndarray or List[numpy.ndarray]

The centered input observation sequence(s).