Class: Nimbus::Forest
- Inherits:
-
Object
- Object
- Nimbus::Forest
- Defined in:
- lib/nimbus/forest.rb
Instance Attribute Summary (collapse)
-
- (Object) options
Returns the value of attribute options.
-
- (Object) size
Returns the value of attribute size.
-
- (Object) trees
Returns the value of attribute trees.
Instance Method Summary (collapse)
- - (Object) grow
-
- (Forest) initialize(config)
constructor
A new instance of Forest.
- - (Object) to_yaml
Constructor Details
- (Forest) initialize(config)
A new instance of Forest
7 8 9 10 11 12 |
# File 'lib/nimbus/forest.rb', line 7 def initialize(config) @trees = [] @options = config @size = config.forest_size raise Nimbus::ForestError, "Forest size parameter (#{@size}) is invalid. You need at least one tree." if @size < 1 end |
Instance Attribute Details
- (Object) options
Returns the value of attribute options
5 6 7 |
# File 'lib/nimbus/forest.rb', line 5 def @options end |
- (Object) size
Returns the value of attribute size
4 5 6 |
# File 'lib/nimbus/forest.rb', line 4 def size @size end |
- (Object) trees
Returns the value of attribute trees
4 5 6 |
# File 'lib/nimbus/forest.rb', line 4 def trees @trees end |
Instance Method Details
- (Object) grow
14 15 16 17 18 19 20 21 22 |
# File 'lib/nimbus/forest.rb', line 14 def grow i=0 @size.times do i+=1 tree = Tree.new @options.tree @trees << tree.seed(@options.training_set.individuals, individuals_random_sample, @options.training_set.ids_fenotypes) #OOB << Tree.traverse OOB por el tree. end end |
- (Object) to_yaml
24 25 26 |
# File 'lib/nimbus/forest.rb', line 24 def to_yaml @trees.to_yaml end |