Class: Ai4r::Classifiers::EvaluationNode
- Inherits:
-
Object
- Object
- Ai4r::Classifiers::EvaluationNode
- Defined in:
- lib/ai4r/classifiers/id3.rb
Overview
:nodoc: all
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#nodes ⇒ Object
readonly
Returns the value of attribute nodes.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
- #get_rules ⇒ Object
-
#initialize(data_labels, index, values, nodes) ⇒ EvaluationNode
constructor
A new instance of EvaluationNode.
- #value(data) ⇒ Object
Constructor Details
#initialize(data_labels, index, values, nodes) ⇒ EvaluationNode
Returns a new instance of EvaluationNode.
274 275 276 277 278 279 |
# File 'lib/ai4r/classifiers/id3.rb', line 274 def initialize(data_labels, index, values, nodes) @index = index @values = values @nodes = nodes @data_labels = data_labels end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
272 273 274 |
# File 'lib/ai4r/classifiers/id3.rb', line 272 def index @index end |
#nodes ⇒ Object (readonly)
Returns the value of attribute nodes.
272 273 274 |
# File 'lib/ai4r/classifiers/id3.rb', line 272 def nodes @nodes end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
272 273 274 |
# File 'lib/ai4r/classifiers/id3.rb', line 272 def values @values end |
Instance Method Details
#get_rules ⇒ Object
287 288 289 290 291 292 293 294 295 296 297 298 299 |
# File 'lib/ai4r/classifiers/id3.rb', line 287 def get_rules rule_set = [] @nodes.each_index do |child_node_index| my_rule = "#{@data_labels[@index]}=='#{@values[child_node_index]}'" child_node = @nodes[child_node_index] child_node_rules = child_node.get_rules child_node_rules.each do |child_rule| child_rule.unshift(my_rule) end rule_set += child_node_rules end return rule_set end |