Module: Clusterer_utils

Overview

This module is used by the classes from the Clusterer module to inherit the following methods (instance and class methods)

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

Instance methods list



19
20
21
# File 'lib/ruby-band/weka/clusterers/clusterers_utils.rb', line 19

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#descriptionObject

the description provided by the Weka Documentation



39
40
41
# File 'lib/ruby-band/weka/clusterers/clusterers_utils.rb', line 39

def description
  globalInfo
end

#evaluate(*args) ⇒ Object

Validate clusterer. If the evaluation needs to be performed on a different dataset this function accepts an optional parameter (an Instances class object)



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/ruby-band/weka/clusterers/clusterers_utils.rb', line 55

def evaluate(*args)
  eval = ClusterEvaluation.new
  eval.setClusterer(self)
  if not args[0]
    if self.class.data
      eval.evaluateClusterer(self.class.data) 
    else
      eval.evaluateClusterer(@dataset)
    end
  else
    eval.evaluateClusterer(args[0])
  end
  puts 'performing evaluation'
  eval.clusterResultsToString
end

#get_centroidsObject

list cluster centroids with coordinates



44
45
46
# File 'lib/ruby-band/weka/clusterers/clusterers_utils.rb', line 44

def get_centroids 
  getClusterCentroids
end

#init_clustererObject



7
8
9
10
# File 'lib/ruby-band/weka/clusterers/clusterers_utils.rb', line 7

def init_clusterer
  set_options(self.class.options) if self.class.options 
  buildClusterer(self.class.data)
end

#init_instance_clusterer(&block) ⇒ Object



12
13
14
15
16
# File 'lib/ruby-band/weka/clusterers/clusterers_utils.rb', line 12

def init_instance_clusterer(&block)
  self.instance_eval(&block)
  #@dataset.setClassIndex(@class_index)
  buildClusterer(@dataset)
end

#list_capabilitiesObject

list cluster’s capabilities with attributes (i.e Numeric, Nominal…)



49
50
51
# File 'lib/ruby-band/weka/clusterers/clusterers_utils.rb', line 49

def list_capabilities
  get_capabilities.to_s
end

#list_optionsObject



34
35
36
# File 'lib/ruby-band/weka/clusterers/clusterers_utils.rb', line 34

def list_options
  listOptions.map {|key| "#{key.synopsis} #{key.description}"}.join("\n")
end

#set_data(data) ⇒ Object

set instance data for the clusterer



24
25
26
# File 'lib/ruby-band/weka/clusterers/clusterers_utils.rb', line 24

def set_data(data)
  @dataset = data 
end

#set_options(options) ⇒ Object

set options for the clusterer



29
30
31
32
# File 'lib/ruby-band/weka/clusterers/clusterers_utils.rb', line 29

def set_options(options)
  options_inst = Utils.splitOptions(options)
  setOptions(options_inst)
end