Class Ai4r::Clusterers::KMeans
In: lib/ai4r/clusterers/k_means.rb
Parent: Clusterer

The k-means algorithm is an algorithm to cluster n objects based on attributes into k partitions, with k < n.

More about K Means algorithm: en.wikipedia.org/wiki/K-means_algorithm

Methods

Attributes

centroids  [R] 
clusters  [R] 
data_set  [R] 
iterations  [R] 
number_of_clusters  [R] 

Public Class methods

Public Instance methods

Build a new clusterer, using data examples found in data_set. Items will be clustered in "number_of_clusters" different clusters.

This function calculates the distance between 2 different instances. By default, it returns the euclidean distance to the power of 2. You can provide a more convinient distance implementation:

1- Overwriting this method

2- Providing a closure to the :distance_function parameter

Classifies the given data item, returning the cluster index it belongs to (0-based).

Protected Instance methods

[Validate]