module RandomForester

Constants

VERSION

Attributes

logger[W]

Public Class Methods

get_model(pmml_file_name) click to toggle source
# File lib/random_forester.rb, line 22
def self.get_model(pmml_file_name)
  xml = xml_from_file_path(pmml_file_name)
  new_model(xml)
end
get_model_type(xml) click to toggle source
# File lib/random_forester.rb, line 46
def self.get_model_type(xml)
  xml.xpath("PMML/MiningModel/@modelName").to_s
end
logger() click to toggle source
# File lib/random_forester.rb, line 15
def logger
  @logger ||= Logger.new($stdout).tap do |log|
    log.progname = self.name
  end
end
new_model(xml) click to toggle source
# File lib/random_forester.rb, line 27
def self.new_model(xml)
  case get_model_type(xml)
    when RANDOM_FOREST_MODEL
      RandomForest.new(xml)
    else
      raise MODEL_NOT_SUPPORTED_ERROR
  end
end
xml_from_file_path(pmml_file_name) click to toggle source
# File lib/random_forester.rb, line 36
def self.xml_from_file_path(pmml_file_name)
  pmml_string = File.open(pmml_file_name, 'rb').read
  xml_from_string(pmml_string)
end
xml_from_string(pmml_string) click to toggle source
# File lib/random_forester.rb, line 41
def self.xml_from_string(pmml_string)
  xml = Nokogiri::XML(pmml_string) { |config| config.noblanks }
  xml.remove_namespaces!
end