Class: Datarobot::AiApi::Output

Inherits:
Object
  • Object
show all
Defined in:
lib/datarobot/ai_api/output.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Output

Given a parsed response body from the API, will create a new ouptut object



8
9
10
11
# File 'lib/datarobot/ai_api/output.rb', line 8

def initialize(options = {})
  set_from_options(options)
  @features = nil
end

Instance Attribute Details

#ai_idObject (readonly)

Returns the value of attribute ai_id.



5
6
7
# File 'lib/datarobot/ai_api/output.rb', line 5

def ai_id
  @ai_id
end

#evaluationObject (readonly)

Returns the value of attribute evaluation.



5
6
7
# File 'lib/datarobot/ai_api/output.rb', line 5

def evaluation
  @evaluation
end

Returns the value of attribute links.



5
6
7
# File 'lib/datarobot/ai_api/output.rb', line 5

def links
  @links
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/datarobot/ai_api/output.rb', line 4

def name
  @name
end

#sourceObject (readonly)

Returns the value of attribute source.



5
6
7
# File 'lib/datarobot/ai_api/output.rb', line 5

def source
  @source
end

#targetObject

Returns the value of attribute target.



4
5
6
# File 'lib/datarobot/ai_api/output.rb', line 4

def target
  @target
end

Class Method Details

.create(ai_id:, learning_session_id:, output_name:) ⇒ Datarobot::AiApi::Output

Creates a new output on the given target for a given dataset

assocaite this output with

Parameters:

  • ai_id (String)

    The ID of the AI to associate this output with

  • learning_session_id (String)

    The ID of the learning session

  • output_name (String)

    The name of the output

Returns:



37
38
39
40
41
42
43
44
# File 'lib/datarobot/ai_api/output.rb', line 37

def self.create(ai_id:, learning_session_id:, output_name:)
  req_body = {learningSessionId: learning_session_id, outputName: output_name}
  Datarobot::AiApi.request_endpoint("/aiapi/ais/#{ai_id}/outputs/", method: "put", body: req_body) do |data|
    output = new(data)
    output.name = output_name
    output
  end
end

Instance Method Details

#featuresArray

gets all feature metadata for learned features of the associated dataset

Returns:

  • (Array)


50
51
52
53
54
55
# File 'lib/datarobot/ai_api/output.rb', line 50

def features
  raise "no ai id" unless @ai_id
  Datarobot::AiApi.request_endpoint("/aiapi/ais/#{@ai_id}/outputs/#{@name}/features") do |data|
    @features = data["features"]
  end
end

#set_from_options(options = {}) ⇒ void

This method returns an undefined value.

Takes a response body from the API. Will set all output attributes from the response body

Parameters:

  • options (Hash) (defaults to: {})

    A parsed response body



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/datarobot/ai_api/output.rb', line 18

def set_from_options(options = {})
  # one-liner replacement for `stringify_keys`
  options = options.collect{|k,v| [k.to_s, v]}.to_h

  @name ||= options.dig("name")
  @target ||= options.dig("target")
  @source ||= options.dig("source")
  @links ||= options.dig("links")
  @ai_id ||= options.dig("aiId")
  @evaluation ||= Datarobot::AiApi::Evaluation.new(options.dig("evaluation") || {})
end