Eccentricity

class gtda.mapper.Eccentricity(exponent=2, metric='euclidean', metric_params={})[source]

Eccentricities of points in a point cloud or abstract metric space.

Let D be a square matrix representing distances between points in a point cloud, or directly defining an abstract metric (or metric-like) space. The eccentricity of point i in the point cloud or abstract metric space is the p-norm (for some p) of row i in D.

Parameters
  • exponent (int or float, optional, default: 2) – p-norm exponent used to calculate eccentricities from the distance matrix.

  • metric (str or function, optional, default: 'euclidean') – Metric to use to compute the distance matrix if point cloud data is passed as input, or 'precomputed' to specify that the input is already a distance matrix. If not 'precomputed', it may be anything allowed by scipy.spatial.distance.pdist.

  • metric_params (dict, optional, default: {}) – Additional keyword arguments for the metric function.

__init__(exponent=2, metric='euclidean', metric_params={})[source]

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

fit(X, y=None)[source]

Do nothing and return the estimator unchanged.

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

Parameters
  • X (array-like of shape (n_samples, n_features) or (n_samples, n_samples)) – Input data.

  • 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 (array-like of shape (n_samples, n_features) or (n_samples, n_samples)) – Input data.

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

Returns

Xt – Column vector of eccentricities of points in X.

Return type

ndarray of shape (n_samples, 1)

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 the eccentricities of points (i.e. rows) in X.

Parameters
  • X (array-like of shape (n_samples, n_features) or (n_samples, n_samples)) – Input data.

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

Returns

Xt – Column vector of eccentricities of points in X.

Return type

ndarray of shape (n_samples, 1)