partition#

KMeansPartitioner.partition(X, k, rng)[исходный код]#

Divide the sample into k clusters by one k-means run.

Параметры:
  • X (UnivariateFloatArray) – One-dimensional sample of finite values.

  • k (int) – Number of clusters.

  • rng (numpy.random.Generator) – Source of randomness; it is passed to kmeans2 and is advanced.

Результат:

Partition matrix of shape (n, k); the order of the columns is arbitrary.

Тип результата:

MultivariateFloatArray

Исключение:
  • InitializationError – k-means left one of the clusters without points. Another run may succeed, except on a sample of a tiny scale: with a range below about 1e-162 the squared distances vanish and every run fails, so the data must be rescaled. NumPy warnings of kmeans2 on such a sample are suppressed: the error explains the failure.

  • ValueError – The values of the sample are so large that squared distances overflow float64; the data must be rescaled.