Class: MLRuby::NaturalLanguageProcessing::TextClassifier::Model
- Inherits:
-
Object
- Object
- MLRuby::NaturalLanguageProcessing::TextClassifier::Model
- Defined in:
- lib/ML_Ruby.rb
Instance Method Summary collapse
-
#initialize(training_data) ⇒ Model
constructor
A new instance of Model.
- #predict(new_data = []) ⇒ Object
Constructor Details
#initialize(training_data) ⇒ Model
Returns a new instance of Model.
81 82 83 |
# File 'lib/ML_Ruby.rb', line 81 def initialize(training_data) @training_data = training_data end |
Instance Method Details
#predict(new_data = []) ⇒ Object
84 85 86 87 88 |
# File 'lib/ML_Ruby.rb', line 84 def predict(new_data=[]) script_path = "#{Gem.loaded_specs['ML_Ruby'].gem_dir}/lib/python/natural_language_processing/text_classifier.py" result = `#{MLRuby::PYTHON_PATH} #{script_path} '#{@training_data}' '#{new_data}'` JSON.parse(result.gsub("'", "\"")) end |