trajminer.clustering
.KMedoids¶
-
class
trajminer.clustering.
KMedoids
(n_clusters, init=None, seed=None, max_iter=300, measure='precomputed', n_jobs=1)¶ K-Medoids Clustering.
- n_clustersint
The number of clusters to group trajectories into.
- init‘park’ or array-like (default=None)
The indices of the trajectories representing the initial cluster medoids. If ‘park’, the medoids will be initialized using the approach introduced in [Park et al., 2009] (see references). If
None
, the initial medoids will be chosen randomly.- seedint (default=None)
The random seed to be used for centroid initialization. If
None
, the default seed of NumPy will be used.- max_iterint (default=300)
The maximum number of iterations to run the algorithm, in case it has not yet converged.
- measureSimilarityMeasure object or str (default=’precomputed’)
The similarity measure to use for computing similarities (see
trajminer.similarity
) or the string ‘precomputed’.- n_jobsint (default=1)
The number of parallel jobs.
-
__init__
(n_clusters, init=None, seed=None, max_iter=300, measure='precomputed', n_jobs=1)¶ Initialize self. See help(type(self)) for accurate signature.
-
fit_predict
(X)¶ Fits and returns the predictions for the given test data.
- Xarray-like, shape (n_samples, max_length, n_features)
Input data. If measure == ‘precomputed’, then X is a distance matrix with shape (n_samples, n_samples).
- predictionsarray-like, shape (n_samples)
Assigned cluster for each input sample.