RedKMeans:
Filter:
redUniverse/Classes (extension) | Red > redUniverse > additional

RedKMeans
ExtensionExtension

k-means clustering

Description

Group points in space. Similar to KMeans quark by Dan Stowell but this one is implemented slightly differently and also uses RedVector.

Class Methods

.new

Arguments:

k

The number of centroids.

max

The maximum number of tries in undecided/borderline situations.

Instance Methods

.reset

This will reset any previously calculated centroids on next update.

.classify

Test only one vector on the current centroids. Rarely needed.

.update

Vectors should be an array of RedVector objects. The vectors can be of any dimension.

.k

.max

.centroids

An array containing the result after the update method is called. It holds -k number of RedVector objects representing the found centroids.

.classifications

An array containing the result after the update method is called. It holds indices and have the same size as the number of items in the vectors array. Each index represents which centroid each vector belongs to. So to look up the closest centroid for vector i, do centroids[classifications[i]].

Examples