Class: Clusterer::Clustering
- Inherits:
-
Object
- Object
- Clusterer::Clustering
- Defined in:
- lib/clusterer/clustering.rb
Class Method Summary collapse
Class Method Details
.cluster(algorithm, objects, options = { }) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/clusterer/clustering.rb', line 26 def cluster(algorithm, objects, = { }) [:no_of_clusters] ||= Math.sqrt(objects.size).to_i idf = InverseDocumentFrequency.new docs = objects.collect {|o| (defined? yield) == "yield" ? Document.new(o, .merge(:idf => idf)) {|o| yield(o)} : Document.new(o, .merge(:idf => idf))} Algorithms.send(algorithm, docs.collect {|d| d.normalize!(idf) }, [:no_of_clusters]) end |