Class: MLRuby::RandomForestRegression::Model

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

Instance Method Summary collapse

Constructor Details

#initialize(x, y) ⇒ Model

Returns a new instance of Model.



38
39
40
41
# File 'lib/ML_Ruby.rb', line 38

def initialize(x, y)
  @x = x
  @y = y
end

Instance Method Details

#predict(next_x) ⇒ Object



42
43
44
45
46
# File 'lib/ML_Ruby.rb', line 42

def predict(next_x)
  script_path = "#{Gem.loaded_specs['ML_Ruby'].gem_dir}/lib/python/random_forest.py"
  result = `#{MLRuby::PYTHON_PATH} #{script_path} "#{@x}, #{@y}, #{next_x}"`
  result.gsub(/\[|\]/, '').split(' ').map(&:strip).map(&:to_f)
end