Module: Functions_utils
- Included in:
- Weka::Classifier::Functions::GaussianProcesses, Weka::Classifier::Functions::LeastMedSq, Weka::Classifier::Functions::LibSVM, Weka::Classifier::Functions::LinearRegression, Weka::Classifier::Functions::PLSClassifier, Weka::Classifier::Functions::RBFNetwork, Weka::Classifier::Functions::SMO, Weka::Classifier::Functions::SMOreg, Weka::Classifier::Functions::SPegasos, Weka::Classifier::Functions::VotedPerceptron, Weka::Classifier::Functions::Winnow
- Defined in:
- lib/ruby-band/weka/classifiers/functions/functions_utils.rb
Overview
This module is used by the ‘functions’ classifiers from ‘functions.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 description from the Weka Javadoc for the selected classifier.
- #init_function ⇒ Object
- #init_instance_classifier(&block) ⇒ Object
-
#list_options ⇒ Object
List available options.
-
#set_class_index(class_index) ⇒ Object
Set a class index for the input dataset.
-
#set_data(data) ⇒ Object
Set instance data for the instance classifier.
- #set_options(options) ⇒ Object
Class Method Details
.included(base) ⇒ Object
Instance methods list
13 14 15 |
# File 'lib/ruby-band/weka/classifiers/functions/functions_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
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/ruby-band/weka/classifiers/functions/functions_utils.rb', line 51 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 description from the Weka Javadoc for the selected classifier
44 45 46 |
# File 'lib/ruby-band/weka/classifiers/functions/functions_utils.rb', line 44 def description puts globalInfo end |
#init_function ⇒ Object
6 7 8 9 10 |
# File 'lib/ruby-band/weka/classifiers/functions/functions_utils.rb', line 6 def init_function (self.class.) if self.class. self.class.data.setClassIndex(self.class.class_index) if self.class.class_index buildClassifier(self.class.data) end |
#init_instance_classifier(&block) ⇒ Object
17 18 19 20 21 |
# File 'lib/ruby-band/weka/classifiers/functions/functions_utils.rb', line 17 def init_instance_classifier(&block) self.instance_eval(&block) @dataset.setClassIndex(@class_index) build_classifier(@dataset) end |
#list_options ⇒ Object
List available options
39 40 41 |
# File 'lib/ruby-band/weka/classifiers/functions/functions_utils.rb', line 39 def listOptions.map {|key| "#{key.synopsis} #{key.description}"}.join("\n") end |
#set_class_index(class_index) ⇒ Object
Set a class index for the input dataset
29 30 31 |
# File 'lib/ruby-band/weka/classifiers/functions/functions_utils.rb', line 29 def set_class_index(class_index) @class_index = class_index end |
#set_data(data) ⇒ Object
Set instance data for the instance classifier
24 25 26 |
# File 'lib/ruby-band/weka/classifiers/functions/functions_utils.rb', line 24 def set_data(data) @dataset = data end |
#set_options(options) ⇒ Object
33 34 35 36 |
# File 'lib/ruby-band/weka/classifiers/functions/functions_utils.rb', line 33 def () = Utils.splitOptions() setOptions() end |