msmbuilder.clustering._kcenters¶
- msmbuilder.clustering._kcenters(metric, ptraj, k=None, distance_cutoff=None, seed=0, verbose=True)[source]¶
Run kcenters clustering algorithm.
Terminates either when k clusters have been identified, or when every data is clustered better than distance_cutoff.
Parameters: metric : msmbuilder.metrics.AbstractDistanceMetric
A metric capable of handling ptraj
ptraj : prepared trajectory
ptraj return by the action of the preceding metric on a msmbuilder trajectory
k : {int, None}
number of desired clusters, or None
distance_cutoff : {float, None}
Stop identifying new clusters once the distance of every data to its cluster center falls below this value. Supply either this or k
seed : int, optional
index of the frame to use as the first cluster center
verbose : bool, optional
print as each new generator is found
Returns: generator_indices : ndarray
indices (with respect to ptraj) of the frames to be considered cluster centers
assignments : ndarray
the cluster center to which each frame is assigned to (1D)
distances : ndarray
distance from each of the frames to the cluster center it was assigned to
See also
- KCenters
- wrapper around this implementation that provides more convenience
Notes
the assignments are numbered with respect to the position in ptraj of the generator, not the position in generator_indices. That is, assignments[10] = 1020 means that the 10th simulation frame is assigned to the 1020th simulation frame, not to the 1020th generator.
References
[R9] Beauchamp, MSMBuilder2