# PearsonDissimilarity¶

class gtda.time_series.PearsonDissimilarity(absolute_value=False, n_jobs=None)[source]

Pearson dissimilarities from collections of multivariate time series.

The sample Pearson correlation coefficients between pairs of components of an $$N$$-variate time series form an $$N \times N$$ matrix $$R$$ with entries

$R_{ij} = \frac{ C_{ij} }{ \sqrt{ C_{ii} C_{jj} } },$

where $$C$$ is the covariance matrix. Setting $$D_{ij} = (1 - R_{ij})/2$$ or $$D_{ij} = 1 - |R_{ij}|$$ we obtain a dissimilarity matrix with entries between 0 and 1.

This transformer computes one dissimilarity matrix per multivariate time series in a collection. Examples of such collections are the outputs of SlidingWindow.

Parameters
• absolute_value (bool, default: False) – Whether absolute values of the Pearson correlation coefficients should be taken. Doing so makes pairs of strongly anti-correlated variables as similar as pairs of strongly correlated ones.

• n_jobs (int or None, optional, default: None) – The number of jobs to use for the computation. None means 1 unless in a joblib.parallel_backend context. -1 means using all processors.

__init__(absolute_value=False, n_jobs=None)[source]

Initialize self. See help(type(self)) for accurate signature.

fit(X, y=None)[source]

Do nothing and return the estimator unchanged.

This method is here to implement the usual scikit-learn API and hence work in pipelines.

Parameters
• X (ndarray of shape (n_samples, n_observations, n_features)) – Input data. Each entry along axis 0 is a sample of n_features different variables, of size n_observations.

• y (None) – There is no need for a target in a transformer, yet the pipeline API requires this parameter.

Returns

self

Return type

object

fit_transform(X, y=None, **fit_params)

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Parameters
• X (ndarray of shape (n_samples, n_observations, n_features)) – Input data. Each entry along axis 0 is a sample of n_features different variables, of size n_observations.

• y (None) – There is no need for a target in a transformer, yet the pipeline API requires this parameter.

Returns

Xt – Array of Pearson dissimilarities.

Return type

ndarray of shape (n_samples, n_features, n_features)

get_params(deep=True)

Get parameters for this estimator.

Parameters

deep (bool, default=True) – If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns

params – Parameter names mapped to their values.

Return type

mapping of string to any

set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters

**params (dict) – Estimator parameters.

Returns

self – Estimator instance.

Return type

object

transform(X, y=None)[source]

Compute Pearson dissimilarities.

Parameters
• X (ndarray of shape (n_samples, n_observations, n_features)) – Input data. Each entry along axis 0 is a sample of n_features different variables, of size n_observations.

• y (None) – There is no need for a target in a transformer, yet the pipeline API requires this parameter.

Returns

Xt – Array of Pearson dissimilarities.

Return type

ndarray of shape (n_samples, n_features, n_features)