Class: Datarobot::AiApi::LearningSession
- Inherits:
-
Object
- Object
- Datarobot::AiApi::LearningSession
- Includes:
- Refreshable
- Defined in:
- lib/datarobot/ai_api/learning_session.rb
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#dataset_id ⇒ Object
readonly
Returns the value of attribute dataset_id.
-
#evaluation ⇒ Object
readonly
Returns the value of attribute evaluation.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Class Method Summary collapse
-
.all(limit: 50, offset: 0) ⇒ Datarobot::AiApi::Page(Datarobot::AiApi::LearningSession)
Retrieves all learning sessions as a paginated resource.
-
.create(dataset_id:, target:) ⇒ Datarobot::AiApi::LearningSession
Creates a new learning session on the given target for a given dataset.
-
.delete(id) ⇒ nil
Deletes a learning session.
-
.find(id, &block) ⇒ Datarobot::AiApi::LearningSession
Retrieves a leanring sessoin given an ID.
Instance Method Summary collapse
-
#deployment ⇒ Object
Gets the deployment for the learning session.
-
#features ⇒ Array
gets all feature metadata for learned features of the associated dataset.
-
#initialize(options = {}) ⇒ LearningSession
constructor
Given a parsed response body from the API, will create a new leanring sessoin object.
-
#set_from_options(options = {}) ⇒ void
Takes a response body from the API.
Methods included from Refreshable
Constructor Details
#initialize(options = {}) ⇒ LearningSession
Given a parsed response body from the API, will create a new leanring sessoin object
62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/datarobot/ai_api/learning_session.rb', line 62 def initialize( = {}) # Suppresses warnings about uninitialized variables @id = nil @name = nil @dataset_id = nil @target = nil @created_at = nil () @features = nil @deployment = nil end |
Instance Attribute Details
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
5 6 7 |
# File 'lib/datarobot/ai_api/learning_session.rb', line 5 def created_at @created_at end |
#dataset_id ⇒ Object (readonly)
Returns the value of attribute dataset_id.
5 6 7 |
# File 'lib/datarobot/ai_api/learning_session.rb', line 5 def dataset_id @dataset_id end |
#evaluation ⇒ Object (readonly)
Returns the value of attribute evaluation.
5 6 7 |
# File 'lib/datarobot/ai_api/learning_session.rb', line 5 def evaluation @evaluation end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/datarobot/ai_api/learning_session.rb', line 5 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/datarobot/ai_api/learning_session.rb', line 5 def name @name end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
5 6 7 |
# File 'lib/datarobot/ai_api/learning_session.rb', line 5 def target @target end |
Class Method Details
.all(limit: 50, offset: 0) ⇒ Datarobot::AiApi::Page(Datarobot::AiApi::LearningSession)
Retrieves all learning sessions as a paginated resource.
13 14 15 16 17 |
# File 'lib/datarobot/ai_api/learning_session.rb', line 13 def self.all(limit: 50, offset: 0) Datarobot::AiApi.request_endpoint('/aiapi/learningSessions/', params: {limit: limit, offset: offset}) do |data| Datarobot::AiApi::Page.new(self, data) end end |
.create(dataset_id:, target:) ⇒ Datarobot::AiApi::LearningSession
Creates a new learning session on the given target for a given dataset
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/datarobot/ai_api/learning_session.rb', line 40 def self.create(dataset_id:, target:) raise "Need both dataset_id and target" unless dataset_id && target name ||= "Learning #{target}" Datarobot::AiApi.request_endpoint('/aiapi/learningSessions/', method: 'post', body: { datasetId: dataset_id, target: target }) do |data| task_data = Datarobot::AiApi.get(data["links"]["result"]) task = Datarobot::AiApi::Task.new(task_data) task.wait_until_complete end end |
.delete(id) ⇒ nil
Deletes a learning session. Returns ‘nil` if the action was successful. Will raise an error if the action was unsuccessful
57 58 59 |
# File 'lib/datarobot/ai_api/learning_session.rb', line 57 def self.delete(id) Datarobot::AiApi.request_endpoint("/aiapi/learningSessions/#{id}", method: "delete") end |
.find(id, &block) ⇒ Datarobot::AiApi::LearningSession
Retrieves a leanring sessoin given an ID.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/datarobot/ai_api/learning_session.rb', line 24 def self.find(id, &block) raise Datarobot::AiApi::NotFoundError, "Cannot find LearningSession with id: nil" if id.nil? Datarobot::AiApi.request_endpoint("/aiapi/learningSessions/#{id}") do |data| if block_given? yield data else self.new(data) end end end |
Instance Method Details
#deployment ⇒ Object
Gets the deployment for the learning session
105 106 107 108 109 |
# File 'lib/datarobot/ai_api/learning_session.rb', line 105 def deployment Datarobot::AiApi.request_endpoint("/aiapi/learningSessions/#{id}/deployment") do |data| @deployment = Datarobot::AiApi::Deployment.new(data) end end |
#features ⇒ Array
gets all feature metadata for learned features of the associated dataset
96 97 98 99 100 101 |
# File 'lib/datarobot/ai_api/learning_session.rb', line 96 def features Datarobot::AiApi.request_endpoint("/aiapi/learningSessions/#{id}/features/") do |data| data = data.collect{|k,v| [k.to_s, v]}.to_h @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 learning session attributes from the response body
80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/datarobot/ai_api/learning_session.rb', line 80 def ( = {}) # one-liner replacement for `stringify_keys` = .collect{|k,v| [k.to_s, v]}.to_h @name = .dig("name") || @name @id = .dig("id") || @id @created_at = .dig("created") || @created_at @dataset_id = .dig("datasetId") || @dataset_id @target = .dig("target") || @target @evaluation = Datarobot::AiApi::Evaluation.new(.dig("evaluation") || {}) end |