Class: MLRuby::NaturalLanguageProcessing::SupportVectorMachine::Model
- Inherits:
-
Object
- Object
- MLRuby::NaturalLanguageProcessing::SupportVectorMachine::Model
- Defined in:
- lib/ML_Ruby.rb
Instance Method Summary collapse
-
#initialize(training_data = [], categories = []) ⇒ Model
constructor
A new instance of Model.
- #predict(new_data = []) ⇒ Object
Constructor Details
#initialize(training_data = [], categories = []) ⇒ Model
Returns a new instance of Model.
93 94 95 96 |
# File 'lib/ML_Ruby.rb', line 93 def initialize(training_data=[], categories=[]) @training_data = training_data @categories = categories end |
Instance Method Details
#predict(new_data = []) ⇒ Object
97 98 99 100 101 |
# File 'lib/ML_Ruby.rb', line 97 def predict(new_data=[]) script_path = "#{Gem.loaded_specs['ML_Ruby'].gem_dir}/lib/python/natural_language_processing/support_vector_machine.py" result = `#{MLRuby::PYTHON_PATH} #{script_path} '#{@training_data}' '#{@categories}' '#{new_data}'` result.gsub("\n", "").gsub(/[\[\]]/, '').split("' '").map { |element| element.gsub(/'/, '') } end |