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.
-
#name ⇒ String
Friendly name to give the session.
-
#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.
-
#supports_feature_importance ⇒ Boolean
readonly
Identifies if this session will provide feature importance scores when completed.
-
#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 34 35 36 37 38 |
# 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, 'supportsFeatureImportance' => :@supports_feature_importance} 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 begin instance_variable_set("@#{k}", v) unless v.nil? rescue # header value not set - exception swallowed. end 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]
84 85 86 |
# File 'lib/nexosis_api/session.rb', line 84 def @column_metadata end |
#datasource_name ⇒ String
The name of the datasource used to run this session
93 94 95 |
# File 'lib/nexosis_api/session.rb', line 93 def datasource_name @datasource_name end |
#end_date ⇒ DateTime
The end date of analysis in this session
75 76 77 |
# File 'lib/nexosis_api/session.rb', line 75 def end_date @end_date end |
#extra_parameters ⇒ Hash
-
included ‘balance’ parameter for classification models
reserved for future extensions
61 62 63 |
# File 'lib/nexosis_api/session.rb', line 61 def extra_parameters @extra_parameters end |
#links ⇒ Array of NexosisApi::Link
associated hypermedia
79 80 81 |
# File 'lib/nexosis_api/session.rb', line 79 def links @links end |
#messages ⇒ Array of Message
A list of warning or error messages optionally returned from session
121 122 123 |
# File 'lib/nexosis_api/session.rb', line 121 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.
105 106 107 |
# File 'lib/nexosis_api/session.rb', line 105 def model_id @model_id end |
#name ⇒ String
Friendly name to give the session
131 132 133 |
# File 'lib/nexosis_api/session.rb', line 131 def name @name end |
#prediction_domain ⇒ String
The type of model if a model creation session
117 118 119 |
# File 'lib/nexosis_api/session.rb', line 117 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
112 113 114 |
# File 'lib/nexosis_api/session.rb', line 112 def prediction_intervals @prediction_intervals end |
#requested_date ⇒ Object
The date this session was orginally submitted
97 98 99 |
# File 'lib/nexosis_api/session.rb', line 97 def requested_date @requested_date end |
#result_interval ⇒ NexosisApi::TimeInterval
The requested result interval. Default is DAY if none was requested during session creation.
88 89 90 |
# File 'lib/nexosis_api/session.rb', line 88 def result_interval @result_interval end |
#session_id ⇒ String
identifier for this sesssion
43 44 45 |
# File 'lib/nexosis_api/session.rb', line 43 def session_id @session_id end |
#start_date ⇒ DateTime
The start date of analysis in this session
70 71 72 |
# File 'lib/nexosis_api/session.rb', line 70 def start_date @start_date end |
#status ⇒ String
Is this session requested, started, or completed
51 52 53 |
# File 'lib/nexosis_api/session.rb', line 51 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
56 57 58 |
# File 'lib/nexosis_api/session.rb', line 56 def status_history @status_history end |
#supports_feature_importance ⇒ Boolean (readonly)
Identifies if this session will provide feature importance scores when completed
126 127 128 |
# File 'lib/nexosis_api/session.rb', line 126 def supports_feature_importance @supports_feature_importance end |
#target_column ⇒ String
The column in the dataset for which this session ran predictions
65 66 67 |
# File 'lib/nexosis_api/session.rb', line 65 def target_column @target_column end |
#type ⇒ String
What type of analysis was run during this session
47 48 49 |
# File 'lib/nexosis_api/session.rb', line 47 def type @type end |