You are viewing an older version (1.17.1).Go to latest (1.18.0)
{ } Raw JSON

bundles / scipy 1.17.1 / scipy / cluster / vq / _kmeans

function

scipy.cluster.vq:_kmeans

source: /scipy/cluster/vq.py:279

Signature

def _kmeans(obs, guess, thresh = 1e-05, xp = None)

Summary

"raw" version of k-means.

Returns

: code_book

The lowest distortion codebook found.

: avg_dist

The average distance a observation is from a code in the book. Lower means the code_book matches the data better.

Examples

Note: not whitened in this example.
import numpy as np
from scipy.cluster.vq import _kmeans
features  = np.array([[ 1.9,2.3],
                      [ 1.5,2.5],
                      [ 0.8,0.6],
                      [ 0.4,1.8],
                      [ 1.0,1.0]])
book = np.array((features[0],features[2]))
✓
_kmeans(features,book)
✗

See also

kmeans

wrapper around k-means

Aliases

  • scipy.cluster.vq._kmeans