Class: MLRuby::LinearRegression::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.



10
11
12
13
# File 'lib/ML_Ruby.rb', line 10

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

Instance Method Details

#predict(next_x) ⇒ Object



14
15
16
17
18
# File 'lib/ML_Ruby.rb', line 14

def predict(next_x)
  script_path = "#{Gem.loaded_specs['ML_Ruby'].gem_dir}/lib/python/linear_regression.py"
  result = `#{MLRuby::PYTHON_PATH} #{script_path} "#{@x}, #{@y}, #{next_x}"`
  result.to_f
end