pycvi.cluster.compute_centers
- pycvi.cluster.compute_centers(X: numpy.ndarray, clusters: List[List[int]] = [], keepdims: bool = False, avg_kwargs: dict = {}) List[numpy.ndarray]
Compute the centers of all clusters.
In the case of static data
For non time-series data, this is simply the average of all datapoints in the given cluster using the usual mean function, and more precisely, calling numpy.mean.
In the case of time series data
For time-series data the cluster center is by default defined as the DBA (DTW barycentric average) as defined by Petitjean et al [DBA]. In this case, additional parameters can be passed in
avg_kwargs, as described in aeon.clustering.averaging.elastic_barycenter_average. By default, uses{ "distance": "msm", "init_barycenter": "medoids", "method": "petitjean", "random_state" : 221}.For more information about the importance of using an elastic average instead of the euclidean mean for time series data, see our example Computing cluster centers
See
pycvi.config.default_ts_average_kwargs()for more information about default averaging kwargs used in PyCVI.[DBA]F. Petitjean, A. Ketterlin, and P. Gan carski, “A global averaging method for dynamic time warping, with applications to clustering,” Pattern Recognition, vol. 44, pp. 678–693, Mar. 2011.
- param X:
The original data.
- type X:
np.ndarray, shape
(N, d*w_t)or(N, w_t, d)- param clusters:
A list of clusters with indices.
- type clusters:
List[List[int]]
- param keepdims:
Whether to keep the dimension
Nof the input cluster, by default False.- type keepdims:
bool, optional
- param avg_kwargs:
Keyword arguments for the average function. See
pycvi.cluster.compute_center()and func:pycvi.cluster.compute_centers for more information.- type avg_kwargs:
dict, optional
- returns:
A list of cluster centers. For each center:
If
keepdims=Truethen the shape is(1, d*w_t)or(1, w_t, d)ifts_dist=True.If
keepdims=Falsethen the shape is(d*w_t)or(w_t, d)ifts_dist=True.
- rtype:
List[np.ndarray]