{ } Raw JSON

bundles / scipy latest / scipy / cluster / _vq / update_cluster_means

cython_function_or_method

scipy.cluster._vq:update_cluster_means

Signature

def   update_cluster_means ( obs labels nc )

Summary

The update-step of K-means. Calculate the mean of observations in each cluster.

Parameters

obs : ndarray

The observation matrix. Each row is an observation. Its dtype must be float32 or float64.

labels : ndarray

The label of each observation. Must be a 1d array.

nc : int

The number of centroids.

Returns

cb : ndarray

The new code book.

has_members : ndarray

A boolean array indicating which clusters have members.

Notes

The empty clusters will be set to all zeros and the corresponding elements in has_members will be False. The upper level function should decide how to deal with them.

Aliases

  • scipy.cluster._vq.update_cluster_means