Method: Nimbus::ClassificationTree#generalization_error_from_oob

Defined in:
lib/nimbus/classification_tree.rb

#generalization_error_from_oob(oob_ids) ⇒ Object

Compute generalization error for the tree.

Traversing the ‘out of bag’ (OOB) sample (those individuals of the training set not used in the building of this tree) through the tree, and comparing the prediction with the real fenotype class of the individual is possible to calculate the error frequency, an unbiased generalization error for the tree.

[View source]

72
73
74
75
76
77
78
79
# File 'lib/nimbus/classification_tree.rb', line 72

def generalization_error_from_oob(oob_ids)
  return nil if (@structure.nil? || @individuals.nil? || @id_to_fenotype.nil?)
  oob_errors = 0.0
  oob_ids.each do |oobi|
    oob_errors += 1 unless @id_to_fenotype[oobi] == Tree.traverse(@structure, individuals[oobi].snp_list)
  end
  @generalization_error = oob_errors / oob_ids.size
end