Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow Ruby Naming convention and Added an extra attributes accessor for training data #27

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/decisiontree/id3_tree.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -260,8 +260,8 @@ def accuracy(data = nil)
end
end

class Ruleset
attr_accessor :rules
class RuleSet
attr_accessor :rules, :train_data

def initialize(attributes, data, default, type)
@attributes = attributes
Expand Down Expand Up @@ -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
Expand Down