Class: MLRuby::RandomForestRegression::Model
- Inherits:
-
Object
- Object
- MLRuby::RandomForestRegression::Model
- Defined in:
- lib/ML_Ruby.rb
Instance Method Summary collapse
-
#initialize(x, y) ⇒ Model
constructor
A new instance of Model.
- #predict(next_x) ⇒ Object
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 |