class KMeansPP::Cluster
Cluster
has a centroid and a group of related points.
Attributes
centroid[RW]
Center of the data set (“centroid”).
@return [Centroid]
points[RW]
Points in this cluster.
@return [Array<Point>]
Public Class Methods
new(centroid, points = [])
click to toggle source
Create a new cluster with a centroid and points.
@param centroid [Centroid] Center point of the data set. @param points [Array<Point>] Points in this cluster.
# File lib/k_means_pp/cluster.rb, line 18 def initialize(centroid, points = []) self.centroid = centroid self.points = points end
Public Instance Methods
to_s()
click to toggle source
A string representation of the cluster.
# File lib/k_means_pp/cluster.rb, line 24 def to_s o = '' o << "Cluster #{centroid}: [\n" points.each { |p| o << " #{p},\n" } o << "]\n" o end