Module: algorithms.clustering.utils


nipy.algorithms.clustering.utils.kmeans(X, nbclusters=2, Labels=None, maxiter=300, delta=0.0001, verbose=0, ninit=1)

kmeans clustering algorithm


X: array of shape (n,p): n = number of items, p = dimension

data array

nbclusters (int), the number of desired clusters

Labels = None array of shape (n) prior Labels.

if None or inadequate a random initilization is performed.

maxiter=300 (int), the maximum number of iterations before convergence

delta: float, optional,

the relative increment in the results before declaring convergence.

verbose: verbosity mode, optionall

ninit: int, optional, number of random initalizations


Centers: array of shape (nbclusters, p),

the centroids of the resulting clusters

Labels : array of size n, the discrete labels of the input items

J (float): the final value of the inertia criterion

nipy.algorithms.clustering.utils.voronoi(x, centers)

Assignment of data items to nearest cluster center


x array of shape (n,p)

n = number of items, p = data dimension

centers, array of shape (k, p) the cluster centers


z vector of shape(n), the resulting assignment