Class: MachineClassifier::Client
- Inherits:
-
Struct
- Object
- Struct
- MachineClassifier::Client
- Defined in:
- lib/machine_classifier/client.rb
Constant Summary collapse
- HEADERS =
{'Content-Type' => 'application/json'}
Instance Attribute Summary collapse
-
#configuration ⇒ Object
Returns the value of attribute configuration.
Instance Method Summary collapse
Instance Attribute Details
#configuration ⇒ Object
Returns the value of attribute configuration
4 5 6 |
# File 'lib/machine_classifier/client.rb', line 4 def configuration @configuration end |
Instance Method Details
#call(text) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/machine_classifier/client.rb', line 7 def call(text) predict = prediction_api.trainedmodels.predict body = {input: {csvInstance: [text]}}.to_json result = api_client.execute( api_method: predict, parameters: {'id' => model_id, 'project' => project_id}, body: body, headers: HEADERS ) data = JSON.parse(result.body) Result.new(data) end |
#categories ⇒ Object
23 24 25 26 |
# File 'lib/machine_classifier/client.rb', line 23 def categories output = ['dataDescription']['outputFeature']['text'] output.map { |category| category['value'] } end |
#confusion ⇒ Object
28 29 30 |
# File 'lib/machine_classifier/client.rb', line 28 def confusion ['modelDescription']['confusionMatrix'] end |
#metadata ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/machine_classifier/client.rb', line 32 def return @metadata if @metadata analyze = prediction_api.trainedmodels.analyze result = api_client.execute( api_method: analyze, parameters: {'id' => model_id, 'project' => project_id}, headers: HEADERS ) @metadata = JSON.parse(result.body) end |