Class: KMeansClusterer::Point

Inherits:
Object
  • Object
show all
Defined in:
lib/kmeans-clusterer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, data, centroid_distances, label = nil) ⇒ Point

Returns a new instance of Point.



64
65
66
67
68
69
# File 'lib/kmeans-clusterer.rb', line 64

def initialize id, data, centroid_distances, label = nil
  @id = id
  @data = data
  @centroid_distances = centroid_distances
  @label = label
end

Instance Attribute Details

#centroid_distancesObject (readonly)

Returns the value of attribute centroid_distances.



61
62
63
# File 'lib/kmeans-clusterer.rb', line 61

def centroid_distances
  @centroid_distances
end

#clusterObject

Returns the value of attribute cluster.



62
63
64
# File 'lib/kmeans-clusterer.rb', line 62

def cluster
  @cluster
end

#dataObject (readonly)

Returns the value of attribute data.



61
62
63
# File 'lib/kmeans-clusterer.rb', line 61

def data
  @data
end

#idObject (readonly)

Returns the value of attribute id.



61
62
63
# File 'lib/kmeans-clusterer.rb', line 61

def id
  @id
end

#labelObject

Returns the value of attribute label.



62
63
64
# File 'lib/kmeans-clusterer.rb', line 62

def label
  @label
end

Instance Method Details

#[](index) ⇒ Object



71
72
73
# File 'lib/kmeans-clusterer.rb', line 71

def [] index
  @data[index]
end

#centroid_distanceObject



87
88
89
# File 'lib/kmeans-clusterer.rb', line 87

def centroid_distance
  @centroid_distances[@cluster.id]
end

#dimensionObject



83
84
85
# File 'lib/kmeans-clusterer.rb', line 83

def dimension
  @data.length
end

#to_aObject



75
76
77
# File 'lib/kmeans-clusterer.rb', line 75

def to_a
  @data.to_a
end

#to_sObject



79
80
81
# File 'lib/kmeans-clusterer.rb', line 79

def to_s
  to_a.to_s
end