Class: Broadlistening::Steps::Clustering

Inherits:
BaseStep
  • Object
show all
Defined in:
lib/broadlistening/steps/clustering.rb

Instance Attribute Summary

Attributes inherited from BaseStep

#config, #context

Instance Method Summary collapse

Methods inherited from BaseStep

#initialize

Constructor Details

This class inherits a constructor from Broadlistening::Steps::BaseStep

Instance Method Details

#executeObject



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/broadlistening/steps/clustering.rb', line 6

def execute
  return context if context.arguments.empty?

  embeddings = build_embeddings_matrix(context.arguments)
  umap_coords = perform_umap(embeddings)
  cluster_results = perform_hierarchical_clustering(umap_coords)

  assign_cluster_info_to_arguments(context.arguments, umap_coords, cluster_results)

  context.cluster_results = cluster_results
  context.umap_coords = umap_coords
  context
end