Class: KMeans
Instance Attribute Summary collapse
-
#centroids ⇒ Object
readonly
Returns the value of attribute centroids.
-
#nodes ⇒ Object
readonly
Returns the value of attribute nodes.
Instance Method Summary collapse
-
#initialize(data, options = {}) ⇒ KMeans
constructor
A new instance of KMeans.
- #inspect ⇒ Object
- #view ⇒ Object
Constructor Details
#initialize(data, options = {}) ⇒ KMeans
Returns a new instance of KMeans.
7 8 9 10 11 12 13 14 15 |
# File 'lib/k_means/k_means.rb', line 7 def initialize(data, ={}) distance_measure = [:distance_measure] || :euclidean_distance @nodes = Node.create_nodes(data, distance_measure) @centroids = [:custom_centroids] || Centroid.create_centroids([:centroids] || 4, @nodes) @verbose = [:verbose] perform_cluster_process end |
Instance Attribute Details
#centroids ⇒ Object (readonly)
Returns the value of attribute centroids.
5 6 7 |
# File 'lib/k_means/k_means.rb', line 5 def centroids @centroids end |
#nodes ⇒ Object (readonly)
Returns the value of attribute nodes.
5 6 7 |
# File 'lib/k_means/k_means.rb', line 5 def nodes @nodes end |