Class: NexosisApi::Session
- Inherits:
-
Object
- Object
- NexosisApi::Session
- Defined in:
- lib/nexosis_api/session.rb
Overview
Class for parsing the results of a session based request
Direct Known Subclasses
ClassifierResult, SessionContest, SessionResponse, SessionResult, SessionSelectionMetrics
Instance Attribute Summary collapse
-
#column_metadata ⇒ Object
The column descriptors for the data in this session will reflect either the metadata sent in, defaults form dataset, or inferred values @return[Array of NexosisApi::Column].
-
#datasource_name ⇒ String
The name of the datasource used to run this session.
-
#end_date ⇒ DateTime
The end date of analysis in this session.
-
#extra_parameters ⇒ Hash
reserved for future extensions.
-
#links ⇒ Array of NexosisApi::Link
associated hypermedia.
-
#messages ⇒ Array of Message
A list of warning or error messages optionally returned from session.
-
#model_id ⇒ String
The id of the model created by this session if any The model id returned here should be used in all future calls to model endpoints - primarily the /models/#model_id/predict endpoint.
-
#prediction_domain ⇒ String
The type of model if a model creation session.
-
#prediction_intervals ⇒ Array
An array of the prediction intervals available for this session’s results.
-
#requested_date ⇒ Object
The date this session was orginally submitted.
-
#result_interval ⇒ NexosisApi::TimeInterval
The requested result interval.
-
#session_id ⇒ String
identifier for this sesssion.
-
#start_date ⇒ DateTime
The start date of analysis in this session.
-
#status ⇒ String
Is this session requested, started, or completed.
-
#status_history ⇒ Array of Hash
Date and status of each status this session has entered.
-
#target_column ⇒ String
The column in the dataset for which this session ran predictions.
-
#type ⇒ String
What type of analysis was run during this session.
Instance Method Summary collapse
-
#initialize(session_hash) ⇒ Session
constructor
A new instance of Session.
Constructor Details
#initialize(session_hash) ⇒ Session
Returns a new instance of Session.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/nexosis_api/session.rb', line 4 def initialize(session_hash) val_map = { 'resultInterval' => :@result_interval, 'dataSourceName' => :@datasource_name, 'modelId' => :@model_id, 'sessionId' => :@session_id, 'availablePredictionIntervals' => :@prediction_intervals, 'startDate' => :@start_date, 'endDate' => :@end_date, 'predictionDomain' => :@prediction_domain, 'extraParameters' => :@extra_parameters, 'targetColumn' => :@target_column, 'statusHistory' => :@status_history } session_hash.each do |k, v| if (k == 'links') @links = v.map { |l| NexosisApi::Link.new(l) } elsif (k == 'columns') @column_metadata = v.reject { |_key, value| value.nil? } .map do |col_key, col_val| NexosisApi::Column.new(col_key, v[col_key]) end elsif (k == 'requestedDate') @requested_date = DateTime.parse(v) elsif (k == 'messages') @messages = v.map { |m| NexosisApi::Message.new(m) } unless v.empty? else instance_variable_set("@#{k}", v) unless v.nil? end instance_variable_set(val_map[k.to_s], v) unless val_map[k.to_s].nil? end end |
Instance Attribute Details
#column_metadata ⇒ Object
The column descriptors for the data in this session
will reflect either the metadata sent in, defaults form dataset, or inferred values
@return[Array of NexosisApi::Column]
79 80 81 |
# File 'lib/nexosis_api/session.rb', line 79 def @column_metadata end |
#datasource_name ⇒ String
The name of the datasource used to run this session
88 89 90 |
# File 'lib/nexosis_api/session.rb', line 88 def datasource_name @datasource_name end |
#end_date ⇒ DateTime
The end date of analysis in this session
70 71 72 |
# File 'lib/nexosis_api/session.rb', line 70 def end_date @end_date end |
#extra_parameters ⇒ Hash
-
included ‘balance’ parameter for classification models
reserved for future extensions
56 57 58 |
# File 'lib/nexosis_api/session.rb', line 56 def extra_parameters @extra_parameters end |
#links ⇒ Array of NexosisApi::Link
associated hypermedia
74 75 76 |
# File 'lib/nexosis_api/session.rb', line 74 def links @links end |
#messages ⇒ Array of Message
A list of warning or error messages optionally returned from session
116 117 118 |
# File 'lib/nexosis_api/session.rb', line 116 def @messages end |
#model_id ⇒ String
This is always empty in time-series sessions (forecast/impact)
The id of the model created by this session if any The model id returned here should be used in all future calls to model endpoints - primarily the /models/#model_id/predict endpoint.
100 101 102 |
# File 'lib/nexosis_api/session.rb', line 100 def model_id @model_id end |
#prediction_domain ⇒ String
The type of model if a model creation session
112 113 114 |
# File 'lib/nexosis_api/session.rb', line 112 def prediction_domain @prediction_domain end |
#prediction_intervals ⇒ Array
-
by default the .5 interval will be returned in results. Consult
this list for other intervals which can be requested.
An array of the prediction intervals available for this session’s results
107 108 109 |
# File 'lib/nexosis_api/session.rb', line 107 def prediction_intervals @prediction_intervals end |
#requested_date ⇒ Object
The date this session was orginally submitted
92 93 94 |
# File 'lib/nexosis_api/session.rb', line 92 def requested_date @requested_date end |
#result_interval ⇒ NexosisApi::TimeInterval
The requested result interval. Default is DAY if none was requested during session creation.
83 84 85 |
# File 'lib/nexosis_api/session.rb', line 83 def result_interval @result_interval end |
#session_id ⇒ String
identifier for this sesssion
38 39 40 |
# File 'lib/nexosis_api/session.rb', line 38 def session_id @session_id end |
#start_date ⇒ DateTime
The start date of analysis in this session
65 66 67 |
# File 'lib/nexosis_api/session.rb', line 65 def start_date @start_date end |
#status ⇒ String
Is this session requested, started, or completed
46 47 48 |
# File 'lib/nexosis_api/session.rb', line 46 def status @status end |
#status_history ⇒ Array of Hash
-
each status object in array is form { date: ‘date’, status: ‘status’ }
Date and status of each status this session has entered
51 52 53 |
# File 'lib/nexosis_api/session.rb', line 51 def status_history @status_history end |
#target_column ⇒ String
The column in the dataset for which this session ran predictions
60 61 62 |
# File 'lib/nexosis_api/session.rb', line 60 def target_column @target_column end |
#type ⇒ String
What type of analysis was run during this session
42 43 44 |
# File 'lib/nexosis_api/session.rb', line 42 def type @type end |