Class: Nimbus::Forest

Inherits:
Object
  • Object
show all
Defined in:
lib/nimbus/forest.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Forest) initialize(config)

Returns 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
  @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