Class: NexosisApi::Outlier

Inherits:
Object
  • Object
show all
Defined in:
lib/nexosis_api/outlier.rb

Overview

Note:

When Nexosis runs a time-series forecast, a smoothed dataset is created in addition to the original. These outlier values represent those which were modified in that smoothed dataset.

Class to hold the parse results of an individual outlier for time-series

Since:

  • 2.4.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(outlier_hash) ⇒ Outlier

Returns a new instance of Outlier.

Since:

  • 2.4.0



6
7
8
9
10
11
12
# File 'lib/nexosis_api/outlier.rb', line 6

def initialize(outlier_hash)
  match_smooth = ->(k, _v) { !k.match(/:smooth/).nil? }
  match_actual = ->(k, _v) { !k.match(/:actual/).nil? }
  @timestamp = DateTime.parse(outlier_hash.fetch(:timeStamp) { |k| outlier_hash.fetch(k.to_s) })
  @smoothed = outlier_hash.select(&match_smooth).first[1].to_f if outlier_hash.any? &match_smooth
  @actual = outlier_hash.select(&match_actual).first[1].to_f if outlier_hash.any? &match_actual
end

Instance Attribute Details

#actualFloat (readonly)

The original value for this target

Returns:

  • (Float)

Since:

  • 2.4.0



20
21
22
# File 'lib/nexosis_api/outlier.rb', line 20

def actual
  @actual
end

#smoothedFloat (readonly)

The smoothed target used in the smoothed data set

Returns:

  • (Float)

Since:

  • 2.4.0



24
25
26
# File 'lib/nexosis_api/outlier.rb', line 24

def smoothed
  @smoothed
end

#timestampDateTime (readonly)

Record timestamp for the given target values

Returns:

  • (DateTime)

Since:

  • 2.4.0



16
17
18
# File 'lib/nexosis_api/outlier.rb', line 16

def timestamp
  @timestamp
end