Class: NexosisApi::Column

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

Overview

class to hold the parsed results of column metadata

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(column_name, value_hash) ⇒ Column

Returns a new instance of Column.



4
5
6
7
8
9
10
# File 'lib/nexosis_api/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

#aggregationString

Note:

Either Sum, Mean, Median, or Mode

The strategy used to aggregate data if requested prediction period is greater than observation period

Returns:

  • (String)


33
34
35
# File 'lib/nexosis_api/column.rb', line 33

def aggregation
  @aggregation
end

#imputationString

Note:

Either Zeroes, Mean, Median, or Mode

The strategy used to imput missing values

Returns:

  • (String)


28
29
30
# File 'lib/nexosis_api/column.rb', line 28

def imputation
  @imputation
end

#nameString

The column header, label, or name

Returns:

  • (String)


13
14
15
# File 'lib/nexosis_api/column.rb', line 13

def name
  @name
end

#roleNexosisApi::ColumnRole

Note:

Either none, timestamp, target, or feature

The role of this column



23
24
25
# File 'lib/nexosis_api/column.rb', line 23

def role
  @role
end

#typeNexosisApi::ColumnType

Note:

Either string, numeric, logical, or date

The data type of this column



18
19
20
# File 'lib/nexosis_api/column.rb', line 18

def type
  @type
end

Class Method Details

.to_json(column_array) ⇒ Object

allows json to be built for api requests



44
45
46
47
48
# File 'lib/nexosis_api/column.rb', line 44

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_hashObject

utility method to format a column description in the way it is expected on input



36
37
38
39
40
41
# File 'lib/nexosis_api/column.rb', line 36

def to_hash
  { name => { 'dataType' => type.to_s,
              'role' => role.to_s,
              'imputation' => imputation.to_s,
              'aggregation' => aggregation.to_s } }
end