DistanceBasedDepth#

class skfda.exploratory.depth.DistanceBasedDepth(metric=LpDistance(p=2, vector_norm=None))[source]#

Functional depth based on a metric.

Parameters:

metric (Metric[T]) –

The metric to use as M in the following depth calculation

\[D(x) = [1 + M(x, \mu)]^{-1}.\]

as explained in [1].

Examples

>>> import skfda
>>> from skfda.exploratory.depth import DistanceBasedDepth
>>> from skfda.misc.metrics import MahalanobisDistance
>>> data_matrix = [[1, 1, 2, 3, 2.5, 2],
...                [0.5, 0.5, 1, 2, 1.5, 1],
...                [-1, -1, -0.5, 1, 1, 0.5],
...                [-0.5, -0.5, -0.5, -1, -1, -1]]
>>> grid_points = [0, 2, 4, 6, 8, 10]
>>> X = skfda.FDataGrid(data_matrix, grid_points)
>>> depth = DistanceBasedDepth(MahalanobisDistance(2))
>>> depth(X).round(1)
array([ 0.4,  0.8,  0.3,  0.3])

References

Methods

fit(X[, y])

Fit the model using X as training data.

fit_transform(X[, y])

Compute the depth or outlyingness of each observation.

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

set_output(*[, transform])

Set output container.

set_params(**params)

Set the parameters of this estimator.

transform(X)

Compute the depth of given observations.

fit(X, y=None)[source]#

Fit the model using X as training data.

Parameters:
  • X (T) – FDataGrid with the training data or array matrix with shape (n_samples, n_samples) if metric=’precomputed’.

  • y (object) – Ignored.

Returns:

self

Return type:

DistanceBasedDepth

fit_transform(X, y=None)[source]#

Compute the depth or outlyingness of each observation.

This computation is done with respect to the whole dataset.

Parameters:
  • X (Input) – Dataset.

  • y (object) – Unused. Kept only for convention.

Returns:

Depth of each observation.

Return type:

ndarray[Any, dtype[float64]]

get_metadata_routing()#

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Returns:

routing – A MetadataRequest encapsulating routing information.

Return type:

MetadataRequest

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:

dict

set_output(*, transform=None)#

Set output container.

See Introducing the set_output API for an example on how to use the API.

Parameters:

transform ({"default", "pandas"}, default=None) –

Configure output of transform and fit_transform.

  • ”default”: Default output format of a transformer

  • ”pandas”: DataFrame output

  • ”polars”: Polars output

  • None: Transform configuration is unchanged

New in version 1.4: “polars” option was added.

Returns:

self – Estimator instance.

Return type:

estimator instance

set_params(**params)#

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as Pipeline). 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:

estimator instance

transform(X)[source]#

Compute the depth of given observations.

Parameters:

X (T) – FDataGrid with the observations to use in the calculation.

Returns:

Array with the depths.

Return type:

ndarray[Any, dtype[float64]]