Class: NexosisApi::Outlier
- Inherits:
-
Object
- Object
- NexosisApi::Outlier
- 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
Instance Attribute Summary collapse
-
#actual ⇒ Float
readonly
The original value for this target.
-
#smoothed ⇒ Float
readonly
The smoothed target used in the smoothed data set.
-
#timestamp ⇒ DateTime
readonly
Record timestamp for the given target values.
Instance Method Summary collapse
-
#initialize(outlier_hash) ⇒ Outlier
constructor
A new instance of Outlier.
Constructor Details
#initialize(outlier_hash) ⇒ Outlier
Returns a new instance of Outlier.
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
#actual ⇒ Float (readonly)
The original value for this target
20 21 22 |
# File 'lib/nexosis_api/outlier.rb', line 20 def actual @actual end |
#smoothed ⇒ Float (readonly)
The smoothed target used in the smoothed data set
24 25 26 |
# File 'lib/nexosis_api/outlier.rb', line 24 def smoothed @smoothed end |
#timestamp ⇒ DateTime (readonly)
Record timestamp for the given target values
16 17 18 |
# File 'lib/nexosis_api/outlier.rb', line 16 def @timestamp end |