class Datarobot::AiApi::Output

Attributes

ai_id[R]
evaluation[R]
name[RW]
source[R]
target[RW]

Public Class Methods

create(ai_id:, learning_session_id:, output_name:) click to toggle source

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

@param [String] ai_id The ID of the AI to associate this output with @param [String] learning_session_id The ID of the learning session assocaite this output with @param [String] output_name The name of the output @return [Datarobot::AiApi::Output]

# 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
new(options = {}) click to toggle source

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

# File lib/datarobot/ai_api/output.rb, line 8
def initialize(options = {})
  set_from_options(options)
  @features = nil
end

Public Instance Methods

features() click to toggle source

gets all feature metadata for learned features of the associated dataset

@return [Array]

# 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 = {}) click to toggle source

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

@param [Hash] options A parsed response body @return [void]

# 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