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.



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

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.



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

def centroid_distances
  @centroid_distances
end

#clusterObject

Returns the value of attribute cluster.



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

def cluster
  @cluster
end

#dataObject (readonly)

Returns the value of attribute data.



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

def data
  @data
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#labelObject

Returns the value of attribute label.



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

def label
  @label
end

Instance Method Details

#[](index) ⇒ Object



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

def [] index
  @data[index]
end

#centroid_distanceObject



91
92
93
# File 'lib/kmeans-clusterer.rb', line 91

def centroid_distance
  @centroid_distances[@cluster.id]
end

#dimensionObject



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

def dimension
  @data.length
end

#to_aObject



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

def to_a
  @data.to_a
end

#to_sObject



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

def to_s
  to_a.to_s
end