pycvi.dist
Low-level distance functions for (non-) time-series data.
Functions
|
Distances between two (groups of) elements. |
|
Pairwise distances within a group of elements. |
|
Applies a given operation on a distance matrix. |
- pycvi.dist.reduce(dist: numpy.ndarray, reduction: Union[str, callable] = None) Union[float, numpy.ndarray]
Applies a given operation on a distance matrix.
reduction available: “sum”, “mean”, “max”, “median”, “min”, “”, None or a callable.
- Parameters:
dist (np.ndarray,) – A distance matrix, either condensed (if pdist) or not (if cdist).
reduction (Union[str, callable], optional) – The type of reduction to apply to the distance matrix, by default None.
- Returns:
The result of applying the reduction on the distance matrix.
- Return type:
Union[float, np.ndarray]
- pycvi.dist.f_pdist(cluster: numpy.ndarray, dist_kwargs: dict = {}) numpy.ndarray
Pairwise distances within a group of elements.
- Parameters:
cluster (np.ndarray, shape (N, d) or (N, w, d) if DTW is used.) – A cluster of N datapoints.
dist_kwargs (dict, optional) – kwargs for scipy.spatial.distance.pdist , by default {}.
- Returns:
The pairwise distance within the cluster (a condensed matrix).
- Return type:
np.ndarray
- Raises:
ShapeError – Raised if cluster doesn’t have the shape (N, d) or (N, w, d)
- pycvi.dist.f_cdist(clusterA: numpy.ndarray, clusterB: numpy.ndarray, dist_kwargs: dict = {}) numpy.ndarray
Distances between two (groups of) elements.
- Parameters:
clusterA (np.ndarray) – A cluster of size NA.
clusterB (np.ndarray) – A cluster of size NB.
dist_kwargs (dict, optional) – kwargs for scipy.spatial.distance.cdist , by default {}.
- Returns:
The pairwise distance matrix between the clusters.
- Return type:
np.ndarray, shape (NA, NB)
- Raises:
ShapeError – Raised if clusterA or clusterB don’t have the shape (N, d) or (N, w, d).