Module: Bayes_utils
- Included in:
- Weka::Classifier::Bayes::AODE, Weka::Classifier::Bayes::BayesianLogisticRegression, Weka::Classifier::Bayes::ComplementNaiveBayes, Weka::Classifier::Bayes::NaiveBayes, Weka::Classifier::Bayes::WAODE
- Defined in:
- lib/ruby-band/weka/classifiers/bayes/bayes_utils.rb
Overview
This module is used by the Bayesian classifiers from ‘bayes.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 the description reported in the Weka Java doc.
- #init_classifier ⇒ Object
- #init_instance_classifier(&block) ⇒ Object
- #list_options ⇒ Object
-
#set_class_index(class_index) ⇒ Object
set class index for the input dataset.
-
#set_data(data) ⇒ Object
set data for instance classifier.
-
#set_options(options) ⇒ Object
set classifier options.
Class Method Details
.included(base) ⇒ Object
Instance methods list
30 31 32 |
# File 'lib/ruby-band/weka/classifiers/bayes/bayes_utils.rb', line 30 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
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/ruby-band/weka/classifiers/bayes/bayes_utils.rb', line 52 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 the description reported in the Weka Java doc
45 46 47 |
# File 'lib/ruby-band/weka/classifiers/bayes/bayes_utils.rb', line 45 def description globalInfo end |
#init_classifier ⇒ Object
7 8 9 10 11 |
# File 'lib/ruby-band/weka/classifiers/bayes/bayes_utils.rb', line 7 def init_classifier (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
13 14 15 16 17 |
# File 'lib/ruby-band/weka/classifiers/bayes/bayes_utils.rb', line 13 def init_instance_classifier(&block) self.instance_eval(&block) @dataset.setClassIndex(@class_index) build_classifier(@dataset) end |
#list_options ⇒ Object
40 41 42 |
# File 'lib/ruby-band/weka/classifiers/bayes/bayes_utils.rb', line 40 def listOptions.map {|key| "#{key.synopsis} #{key.description}"}.join("\n") end |
#set_class_index(class_index) ⇒ Object
set class index for the input dataset
25 26 27 |
# File 'lib/ruby-band/weka/classifiers/bayes/bayes_utils.rb', line 25 def set_class_index(class_index) @class_index = class_index end |
#set_data(data) ⇒ Object
set data for instance classifier
20 21 22 |
# File 'lib/ruby-band/weka/classifiers/bayes/bayes_utils.rb', line 20 def set_data(data) @dataset = data end |
#set_options(options) ⇒ Object
set classifier options
35 36 37 38 |
# File 'lib/ruby-band/weka/classifiers/bayes/bayes_utils.rb', line 35 def () = Utils.splitOptions() setOptions() end |