nexosis_api 1.1.2 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,26 +1,26 @@
1
- require 'nexosis_api/session'
2
-
3
- module NexosisApi
4
- #Class to parse the results from a new session
5
- class SessionResponse < Session
6
- def initialize(forecast_hash)
7
- forecast_hash.each do |k,v|
8
- if(k == "session")
9
- super(v) unless v.nil?
10
- elsif(k == "nexosis-request-cost")
11
- instance_variable_set("@cost", v[0]) unless v.nil?
12
- elsif(k == "nexosis-account-balance")
13
- instance_variable_set("@account_balance", v[0]) unless v.nil?
14
- end
15
- end
16
- end
17
-
18
- # The cost of this session with currency identifier
19
- # @return [String]
20
- attr_accessor :cost
21
-
22
- # Remaining balance after charge for this session
23
- # @return [String]
24
- attr_accessor :account_balance
25
- end
26
- end
1
+ require 'nexosis_api/session'
2
+
3
+ module NexosisApi
4
+ #Class to parse the results from a new session
5
+ class SessionResponse < Session
6
+ def initialize(forecast_hash)
7
+ forecast_hash.each do |k, v|
8
+ if(k == 'session')
9
+ super(v) unless v.nil?
10
+ elsif(k == 'nexosis-request-cost')
11
+ instance_variable_set('@cost', v[0]) unless v.nil?
12
+ elsif(k == 'nexosis-account-balance')
13
+ instance_variable_set('@account_balance', v[0]) unless v.nil?
14
+ end
15
+ end
16
+ end
17
+
18
+ # The cost of this session with currency identifier
19
+ # @return [String]
20
+ attr_accessor :cost
21
+
22
+ # Remaining balance after charge for this session
23
+ # @return [String]
24
+ attr_accessor :account_balance
25
+ end
26
+ end
@@ -1,23 +1,23 @@
1
- module NexosisApi
2
- # Class for parsing the results of a completed session
3
- class SessionResult < Session
4
- def initialize(sessionHash)
5
- sessionHash.each do |k,v|
6
- if k == "metrics"
7
- instance_variable_set("@#{k}", NexosisApi::ImpactMetric.new(v)) unless v.nil?
8
- else
9
- instance_variable_set("@#{k}", v) unless v.nil?
10
- end
11
- end
12
- super(sessionHash.reject {|k,v| k == "data" || k == "metrics"})
13
- end
14
-
15
- # The impact analysis if this session type is impact
16
- # @return [NexosisApi::ImpactMetric]
17
- attr_accessor :metrics
18
-
19
- # The result data in a hash with the name of the target column
20
- # @return [Hash]
21
- attr_accessor :data
22
- end
23
- end
1
+ module NexosisApi
2
+ # Class for parsing the results of a completed session
3
+ class SessionResult < Session
4
+ def initialize(session_hash)
5
+ session_hash.each do |k, v|
6
+ if k == 'metrics'
7
+ instance_variable_set("@#{k}", NexosisApi::ImpactMetric.new(v)) unless v.nil?
8
+ else
9
+ instance_variable_set("@#{k}", v) unless v.nil?
10
+ end
11
+ end
12
+ super(session_hash.reject { |k,v| k == 'data' || k == 'metrics' })
13
+ end
14
+
15
+ # The impact analysis if this session type is impact
16
+ # @return [NexosisApi::ImpactMetric]
17
+ attr_accessor :metrics
18
+
19
+ # The result data in a hash with the name of the target column
20
+ # @return [Hash]
21
+ attr_accessor :data
22
+ end
23
+ end
@@ -1,15 +1,15 @@
1
- module NexosisApi
2
- #constants for the date/time interval (e.g. Day, Hour) at which predictions should be generated.
3
- module TimeInterval
4
- # results summarized by hour
5
- HOUR = :hour
6
- # results summarized by day. Default option.
7
- DAY = :day
8
- # results summarized by week
9
- WEEK = :week
10
- # results summarized by month
11
- MONTH = :month
12
- # results summarized by year
13
- YEAR = :year
14
- end
15
- end
1
+ module NexosisApi
2
+ # constants for the date/time interval (e.g. Day, Hour) at which predictions should be generated.
3
+ module TimeInterval
4
+ # results summarized by hour
5
+ HOUR = :hour
6
+ # results summarized by day. Default option.
7
+ DAY = :day
8
+ # results summarized by week
9
+ WEEK = :week
10
+ # results summarized by month
11
+ MONTH = :month
12
+ # results summarized by year
13
+ YEAR = :year
14
+ end
15
+ end
@@ -0,0 +1,13 @@
1
+ module NexosisApi
2
+ # Class to hold the parsed results of a view data retrieval
3
+ class ViewData < ViewDefinition
4
+ def initialize(viewdata_hash)
5
+ @data = viewdata_hash['data']
6
+ super(viewdata_hash.reject { |k| k == 'data' })
7
+ end
8
+
9
+ # An array of hashes representing the processed data of the view
10
+ # @return [Array of Hash] - one hash per row of data where key = column name
11
+ attr_accessor :data
12
+ end
13
+ end
@@ -0,0 +1,51 @@
1
+ module NexosisApi
2
+ # class to hold the parsed results of a view
3
+ class ViewDefinition
4
+ def initialize(view_hash)
5
+ view_hash.each do |k, v|
6
+ if k == 'viewName'
7
+ @view_name = v unless v.nil?
8
+ elsif k == 'dataSetName'
9
+ @dataset_name = v unless v.nil?
10
+ elsif k == 'columns'
11
+ next if v.nil?
12
+ @column_metadata = v.reject { |value| value.nil? } .map { |col_name, col_hash| NexosisApi::Column.new(col_name, col_hash)}
13
+ elsif k == 'joins'
14
+ @joins = v.reject(&:nil?).map { |join| NexosisApi::Join.new(join) }
15
+ end
16
+ end
17
+ end
18
+
19
+ # The name of the view uploaded and saved
20
+ # @return [String]
21
+ attr_accessor :view_name
22
+
23
+ # The name of the dataset on the left of the join
24
+ # @return [String]
25
+ attr_accessor :dataset_name
26
+
27
+ # Descriptive information about the columns
28
+ # @return [Array of NexosisApi::Column]
29
+ attr_accessor :column_metadata
30
+
31
+ # The join configuration for this view
32
+ # @return [Array of NexosisApi::Join]
33
+ attr_accessor :joins
34
+
35
+ def to_json
36
+ hash = {}
37
+ hash['dataSetName'] = dataset_name
38
+ if column_metadata.nil? == false
39
+ hash['columns'] = {}
40
+ column_metadata.each do |column|
41
+ hash['columns'].merge!(column.to_hash)
42
+ end
43
+ end
44
+ hash['joins'] = []
45
+ joins.each do |join|
46
+ hash['joins'] << join.to_hash
47
+ end
48
+ hash.to_json
49
+ end
50
+ end
51
+ end
data/nexosisapi.gemspec CHANGED
@@ -1,21 +1,21 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
-
5
- Gem::Specification.new do |spec|
6
- spec.add_development_dependency 'bundler', '~> 1.0'
7
- spec.add_dependency 'httparty', '>= 0.15'
8
- spec.authors = ["Nexosis,Inc"]
9
- spec.description = %q{Nexosis API client}
10
- spec.email = ['support@nexosis.com']
11
- spec.files = %w(nexosisapi.gemspec)
12
- spec.files += Dir.glob("lib/**/*.rb")
13
- spec.homepage = 'https://github.com/nexosis/nexosisclient-rb'
14
- spec.licenses = ['Apache 2.0']
15
- spec.name = 'nexosis_api'
16
- spec.require_paths = ['lib']
17
- spec.required_ruby_version = '>= 2.0.0'
18
- spec.summary = "Ruby client for working with the Nexosis API"
19
- spec.version = '1.1.2'
20
- spec.metadata["yard.run"] = "yri"
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.add_development_dependency 'bundler', '~> 1.0'
7
+ spec.add_dependency 'httparty', '>= 0.15'
8
+ spec.authors = ["Nexosis,Inc"]
9
+ spec.description = %q{Nexosis API client}
10
+ spec.email = ['support@nexosis.com']
11
+ spec.files = %w(nexosisapi.gemspec)
12
+ spec.files += Dir.glob("lib/**/*.rb")
13
+ spec.homepage = 'https://github.com/nexosis/nexosisclient-rb'
14
+ spec.licenses = ['Apache-2.0']
15
+ spec.name = 'nexosis_api'
16
+ spec.require_paths = ['lib']
17
+ spec.required_ruby_version = '>= 2.0.0'
18
+ spec.summary = "Ruby client for working with the Nexosis API"
19
+ spec.version = '1.2.0'
20
+ spec.metadata["yard.run"] = "yri"
21
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nexosis_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nexosis,Inc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-08 00:00:00.000000000 Z
11
+ date: 2017-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -53,25 +53,30 @@ files:
53
53
  - lib/nexosis_api/client/datasets.rb
54
54
  - lib/nexosis_api/client/imports.rb
55
55
  - lib/nexosis_api/client/sessions.rb
56
+ - lib/nexosis_api/client/views.rb
57
+ - lib/nexosis_api/column.rb
58
+ - lib/nexosis_api/column_options.rb
56
59
  - lib/nexosis_api/column_role.rb
57
60
  - lib/nexosis_api/column_type.rb
58
- - lib/nexosis_api/dataset_column.rb
59
61
  - lib/nexosis_api/dataset_data.rb
60
62
  - lib/nexosis_api/dataset_model.rb
61
63
  - lib/nexosis_api/dataset_summary.rb
62
64
  - lib/nexosis_api/http_exception.rb
63
65
  - lib/nexosis_api/impact_metric.rb
64
66
  - lib/nexosis_api/imports_response.rb
67
+ - lib/nexosis_api/join.rb
65
68
  - lib/nexosis_api/link.rb
66
69
  - lib/nexosis_api/metric.rb
67
70
  - lib/nexosis_api/session.rb
68
71
  - lib/nexosis_api/session_response.rb
69
72
  - lib/nexosis_api/session_result.rb
70
73
  - lib/nexosis_api/time_interval.rb
74
+ - lib/nexosis_api/view_data.rb
75
+ - lib/nexosis_api/view_definition.rb
71
76
  - nexosisapi.gemspec
72
77
  homepage: https://github.com/nexosis/nexosisclient-rb
73
78
  licenses:
74
- - Apache 2.0
79
+ - Apache-2.0
75
80
  metadata:
76
81
  yard.run: yri
77
82
  post_install_message:
@@ -90,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
95
  version: '0'
91
96
  requirements: []
92
97
  rubyforge_project:
93
- rubygems_version: 2.5.2
98
+ rubygems_version: 2.6.11
94
99
  signing_key:
95
100
  specification_version: 4
96
101
  summary: Ruby client for working with the Nexosis API
@@ -1,47 +0,0 @@
1
- module NexosisApi
2
- # class to hold the parsed results of a dataset column
3
- class DatasetColumn
4
- def initialize(column_name, value_hash)
5
- @name = column_name
6
- @type = NexosisApi::ColumnType.const_get(value_hash['dataType'].upcase) unless value_hash['dataType'].nil?
7
- @role = NexosisApi::ColumnRole.const_get(value_hash['role'].upcase) unless value_hash['role'].nil?
8
- @imputation = value_hash['imputation'] unless value_hash['imputation'].nil?
9
- @aggregation = value_hash['aggregation'] unless value_hash['aggregation'].nil?
10
- end
11
- # The column header, label, or name
12
- # @return [String]
13
- attr_accessor :name
14
-
15
-
16
- # The data type of this column
17
- # @note Either string, numeric, logical, or date
18
- # @return [NexosisApi::ColumnType]
19
- attr_accessor :type
20
-
21
- # The role of this column
22
- # @note Either none, timestamp, target, or feature
23
- # @return [NexosisApi::ColumnRole]
24
- attr_accessor :role
25
-
26
- # The strategy used to imput missing values
27
- # @note Either Zeroes, Mean, Median, or Mode
28
- # @return [String]
29
- attr_accessor :imputation
30
-
31
- # The strategy used to aggregate data if requested prediction period is greater than observation period
32
- # @note Either Sum, Mean, Median, or Mode
33
- # @return [String]
34
- attr_accessor :aggregation
35
-
36
- # utility method to format a column description in the way it is expected on input
37
- def to_hash
38
- { self.name => { 'dataType' => self.type.to_s, 'role' => self.role.to_s }}
39
- end
40
-
41
- def self.to_json(column_array)
42
- result = {}
43
- column_array.each {|col| result[col.to_hash.keys[0]] = col.to_hash.values[0] }
44
- result
45
- end
46
- end
47
- end