class Scoruby::Models::RandomForest::Data

Constants

FEATURES_XPATH
RF_FOREST_XPATH

Public Class Methods

new(xml) click to toggle source
# File lib/scoruby/models/random_forest/data.rb, line 10
def initialize(xml)
  @xml = xml
end

Public Instance Methods

categorical_features() click to toggle source
# File lib/scoruby/models/random_forest/data.rb, line 20
def categorical_features
  @categorical_features ||= fetch_categorical_features
end
continuous_features() click to toggle source
# File lib/scoruby/models/random_forest/data.rb, line 24
def continuous_features
  @continuous_features ||= fetch_continuous_features
end
decision_trees() click to toggle source
# File lib/scoruby/models/random_forest/data.rb, line 14
def decision_trees
  @decision_trees ||= @xml.xpath(RF_FOREST_XPATH).map do |xml_tree|
    DecisionTree.new(xml_tree)
  end
end

Private Instance Methods

categorical_predicates() click to toggle source
# File lib/scoruby/models/random_forest/data.rb, line 43
def categorical_predicates
  @xml.xpath('//SimpleSetPredicate')
end
continuous_predicates() click to toggle source
# File lib/scoruby/models/random_forest/data.rb, line 47
def continuous_predicates
  @xml.xpath('//SimplePredicate')
end
fetch_categorical_features() click to toggle source
# File lib/scoruby/models/random_forest/data.rb, line 36
def fetch_categorical_features
  categorical_predicates.each_with_object(Hash.new([])) do |xml, res|
    predicate = Predicates::SimpleSetPredicate.new(xml)
    res[predicate.field] = res[predicate.field] | predicate.array
  end
end
fetch_continuous_features() click to toggle source
# File lib/scoruby/models/random_forest/data.rb, line 30
def fetch_continuous_features
  continuous_predicates.map do |xml|
    Predicates::SimplePredicate.new(xml).field
  end.uniq
end