class NexosisApi::Session

Class for parsing the results of a session based request

Attributes

column_metadata[RW]

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[RW]

The name of the datasource used to run this session @return [String] - the dataset or view name @since 1.2.0

end_date[RW]

The end date of analysis in this session @return [DateTime] @since 1.4.0

extra_parameters[RW]

reserved for future extensions @return [Hash] @note - included 'balance' parameter for classification models

messages[RW]

A list of warning or error messages optionally returned from session @return [Array of Message]

model_id[RW]

The id of the model created by this session if any @return [String] a uuid/buid format unique string for the model @since 1.3.0 @note This is always empty in time-series sessions (forecast/impact) The model id returned here should be used in all future calls to model endpoints - primarily the /models/{model_id}/predict endpoint.

name[RW]

Friendly name to give the session @return [String] @since 3.0.4

prediction_domain[RW]

The type of model if a model creation session @return [String] @since 1.4.1

prediction_intervals[RW]

An array of the prediction intervals available for this session's results @return [Array] @note - by default the .5 interval will be returned in results. Consult

this list for other intervals which can be requested.

@since 1.4.0

requested_date[RW]

The date this session was orginally submitted @since 1.3.0

result_interval[RW]

The requested result interval. Default is DAY if none was requested during session creation. @return [NexosisApi::TimeInterval]

session_id[RW]

identifier for this sesssion @return [String] @since 1.4.0

start_date[RW]

The start date of analysis in this session @return [DateTime] @since 1.4.0

status[RW]

Is this session requested, started, or completed @return [String]

status_history[RW]

Date and status of each status this session has entered @return [Array of Hash] @note - each status object in array is form { date: 'date', status: 'status' }

supports_feature_importance[R]

Identifies if this session will provide feature importance scores when completed @return [Boolean] @since 2.4.0

target_column[RW]

The column in the dataset for which this session ran predictions @return [String]

type[RW]

What type of analysis was run during this session @return [String]

Public Class Methods

new(session_hash) click to toggle source
# 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