Class: NexosisApi::DatasetColumn
- Inherits:
-
Object
- Object
- NexosisApi::DatasetColumn
- Defined in:
- lib/nexosis_api/dataset_column.rb
Overview
class to hold the parsed results of a dataset column
Instance Attribute Summary collapse
-
#aggregation ⇒ String
The strategy used to aggregate data if requested prediction period is greater than observation period.
-
#imputation ⇒ String
The strategy used to imput missing values.
-
#name ⇒ String
The column header, label, or name.
-
#role ⇒ NexosisApi::ColumnRole
The role of this column.
-
#type ⇒ NexosisApi::ColumnType
The data type of this column.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(column_name, value_hash) ⇒ DatasetColumn
constructor
A new instance of DatasetColumn.
-
#to_hash ⇒ Object
utility method to format a column description in the way it is expected on input.
Constructor Details
#initialize(column_name, value_hash) ⇒ DatasetColumn
Returns a new instance of DatasetColumn.
4 5 6 7 8 9 10 |
# File 'lib/nexosis_api/dataset_column.rb', line 4 def initialize(column_name, value_hash) @name = column_name @type = NexosisApi::ColumnType.const_get(value_hash['dataType'].upcase) unless value_hash['dataType'].nil? @role = NexosisApi::ColumnRole.const_get(value_hash['role'].upcase) unless value_hash['role'].nil? @imputation = value_hash['imputation'] unless value_hash['imputation'].nil? @aggregation = value_hash['aggregation'] unless value_hash['aggregation'].nil? end |
Instance Attribute Details
#aggregation ⇒ String
Either Sum, Mean, Median, or Mode
The strategy used to aggregate data if requested prediction period is greater than observation period
34 35 36 |
# File 'lib/nexosis_api/dataset_column.rb', line 34 def aggregation @aggregation end |
#imputation ⇒ String
Either Zeroes, Mean, Median, or Mode
The strategy used to imput missing values
29 30 31 |
# File 'lib/nexosis_api/dataset_column.rb', line 29 def imputation @imputation end |
#name ⇒ String
The column header, label, or name
13 14 15 |
# File 'lib/nexosis_api/dataset_column.rb', line 13 def name @name end |
#role ⇒ NexosisApi::ColumnRole
Either none, timestamp, target, or feature
The role of this column
24 25 26 |
# File 'lib/nexosis_api/dataset_column.rb', line 24 def role @role end |
#type ⇒ NexosisApi::ColumnType
Either string, numeric, logical, or date
The data type of this column
19 20 21 |
# File 'lib/nexosis_api/dataset_column.rb', line 19 def type @type end |
Class Method Details
.to_json(column_array) ⇒ Object
41 42 43 44 45 |
# File 'lib/nexosis_api/dataset_column.rb', line 41 def self.to_json(column_array) result = {} column_array.each {|col| result[col.to_hash.keys[0]] = col.to_hash.values[0] } result end |
Instance Method Details
#to_hash ⇒ Object
utility method to format a column description in the way it is expected on input
37 38 39 |
# File 'lib/nexosis_api/dataset_column.rb', line 37 def to_hash { self.name => { 'dataType' => self.type.to_s, 'role' => self.role.to_s }} end |