Module: Mi_utils
- Included in:
- Weka::Classifier::Mi::CitationKNN, Weka::Classifier::Mi::MDD, Weka::Classifier::Mi::MIBoost, Weka::Classifier::Mi::MIDD, Weka::Classifier::Mi::MIEMDD, Weka::Classifier::Mi::MILR, Weka::Classifier::Mi::MINND, Weka::Classifier::Mi::MIOptimalBall, Weka::Classifier::Mi::MISMO, Weka::Classifier::Mi::MISVM, Weka::Classifier::Mi::MIWrapper, Weka::Classifier::Mi::SimpleMI
- Defined in:
- lib/ruby-band/weka/classifiers/mi/mi_utils.rb
Overview
This module is used by the ‘mi’ classifiers from ‘mi.rb’ to inherit the following methods (instance and class methods)
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(base) ⇒ Object
Instance methods list.
Instance Method Summary collapse
-
#cross_validate(fold) ⇒ Object
perform crossvalidation on a trained classifier ARGV: fold -> ‘int’ value.
-
#description ⇒ Object
Return a short description for the current classifier.
- #init_instance_classifier(&block) ⇒ Object
- #init_mi ⇒ Object
-
#list_options ⇒ Object
List options for the selected classifier.
-
#set_class_index(class_index) ⇒ Object
Set class index for the input dataset.
-
#set_data(data) ⇒ Object
Set input data for the selected classifier ARGV: data -> an Instances class object.
- #set_options(options) ⇒ Object
Class Method Details
.included(base) ⇒ Object
Instance methods list
13 14 15 |
# File 'lib/ruby-band/weka/classifiers/mi/mi_utils.rb', line 13 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#cross_validate(fold) ⇒ Object
perform crossvalidation on a trained classifier ARGV: fold -> ‘int’ value
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/ruby-band/weka/classifiers/mi/mi_utils.rb', line 53 def cross_validate(fold) if self.class.data eval = Weka::Classifier::Evaluation.new self.class.data eval.crossValidateModel(self.class.ancestors[2].new, self.class.data, fold.to_java(:int), Random.new(1)) eval.summary else eval = Weka::Classifier::Evaluation.new @dataset eval.crossValidateModel(self.class.ancestors[1].new, @dataset, fold.to_java(:int), Random.new(1)) eval.summary end end |
#description ⇒ Object
Return a short description for the current classifier
46 47 48 |
# File 'lib/ruby-band/weka/classifiers/mi/mi_utils.rb', line 46 def description puts globalInfo end |
#init_instance_classifier(&block) ⇒ Object
17 18 19 20 21 |
# File 'lib/ruby-band/weka/classifiers/mi/mi_utils.rb', line 17 def init_instance_classifier(&block) self.instance_eval(&block) @dataset.setClassIndex(@class_index) build_classifier(@dataset) end |
#init_mi ⇒ Object
6 7 8 9 10 |
# File 'lib/ruby-band/weka/classifiers/mi/mi_utils.rb', line 6 def init_mi (self.class.) if self.class. self.class.data.setClassIndex(self.class.class_index) if self.class.class_index buildClassifier(self.class.data) end |
#list_options ⇒ Object
List options for the selected classifier
41 42 43 |
# File 'lib/ruby-band/weka/classifiers/mi/mi_utils.rb', line 41 def listOptions.each {|key| puts "#{key.synopsis} #{key.description}"} end |
#set_class_index(class_index) ⇒ Object
Set class index for the input dataset
31 32 33 |
# File 'lib/ruby-band/weka/classifiers/mi/mi_utils.rb', line 31 def set_class_index(class_index) @class_index = class_index end |
#set_data(data) ⇒ Object
Set input data for the selected classifier ARGV: data -> an Instances class object
26 27 28 |
# File 'lib/ruby-band/weka/classifiers/mi/mi_utils.rb', line 26 def set_data(data) @dataset = data end |
#set_options(options) ⇒ Object
35 36 37 38 |
# File 'lib/ruby-band/weka/classifiers/mi/mi_utils.rb', line 35 def () = Utils.splitOptions() setOptions() end |