Class: KMeansClusterer::Point
- Inherits:
-
Object
- Object
- KMeansClusterer::Point
- Defined in:
- lib/kmeans-clusterer.rb
Instance Attribute Summary collapse
-
#centroid_distances ⇒ Object
readonly
Returns the value of attribute centroid_distances.
-
#cluster ⇒ Object
Returns the value of attribute cluster.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#label ⇒ Object
Returns the value of attribute label.
Instance Method Summary collapse
- #[](index) ⇒ Object
- #centroid_distance ⇒ Object
- #dimension ⇒ Object
-
#initialize(id, data, centroid_distances, label = nil) ⇒ Point
constructor
A new instance of Point.
- #to_a ⇒ Object
- #to_s ⇒ Object
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_distances ⇒ Object (readonly)
Returns the value of attribute centroid_distances.
61 62 63 |
# File 'lib/kmeans-clusterer.rb', line 61 def centroid_distances @centroid_distances end |
#cluster ⇒ Object
Returns the value of attribute cluster.
62 63 64 |
# File 'lib/kmeans-clusterer.rb', line 62 def cluster @cluster end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
61 62 63 |
# File 'lib/kmeans-clusterer.rb', line 61 def data @data end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
61 62 63 |
# File 'lib/kmeans-clusterer.rb', line 61 def id @id end |
#label ⇒ Object
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_distance ⇒ Object
87 88 89 |
# File 'lib/kmeans-clusterer.rb', line 87 def centroid_distance @centroid_distances[@cluster.id] end |
#dimension ⇒ Object
83 84 85 |
# File 'lib/kmeans-clusterer.rb', line 83 def dimension @data.length end |
#to_a ⇒ Object
75 76 77 |
# File 'lib/kmeans-clusterer.rb', line 75 def to_a @data.to_a end |
#to_s ⇒ Object
79 80 81 |
# File 'lib/kmeans-clusterer.rb', line 79 def to_s to_a.to_s end |