From 94626bfe56bc8037f12a8d016729d1aee2b50752 Mon Sep 17 00:00:00 2001 From: Rokibul Hasan Date: Fri, 19 Feb 2016 15:59:43 +0600 Subject: [PATCH 1/2] Rename class Ruleset as RuleSet and respective methods --- lib/decisiontree/id3_tree.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/decisiontree/id3_tree.rb b/lib/decisiontree/id3_tree.rb index b0702c8..bc0dac6 100755 --- a/lib/decisiontree/id3_tree.rb +++ b/lib/decisiontree/id3_tree.rb @@ -133,8 +133,8 @@ def graph(filename, file_type = 'png') dgp.write_to_file("#{filename}.#{file_type}", file_type) end - def ruleset - rs = Ruleset.new(@attributes, @data, @default, @type) + def rule_set + rs = RuleSet.new(@attributes, @data, @default, @type) rs.rules = build_rules rs end @@ -260,7 +260,7 @@ def accuracy(data = nil) end end - class Ruleset + class RuleSet attr_accessor :rules def initialize(attributes, data, default, type) @@ -322,7 +322,7 @@ def initialize(attributes, data, default, type) def train(data = @data, attributes = @attributes, default = @default) @classifiers = [] - 10.times { @classifiers << Ruleset.new(attributes, data, default, @type) } + 10.times { @classifiers << RuleSet.new(attributes, data, default, @type) } @classifiers.each do |c| c.train(data, attributes, default) end From 20e7d8388e89c8974923bc2bab4092b28da556b3 Mon Sep 17 00:00:00 2001 From: Rokibul Hasan Date: Fri, 19 Feb 2016 16:01:15 +0600 Subject: [PATCH 2/2] Added a new attributes accessor for train data --- lib/decisiontree/id3_tree.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/decisiontree/id3_tree.rb b/lib/decisiontree/id3_tree.rb index bc0dac6..0b47129 100755 --- a/lib/decisiontree/id3_tree.rb +++ b/lib/decisiontree/id3_tree.rb @@ -261,7 +261,7 @@ def accuracy(data = nil) end class RuleSet - attr_accessor :rules + attr_accessor :rules, :train_data def initialize(attributes, data, default, type) @attributes = attributes