nexosis_api 1.0.6 → 1.1.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.
- checksums.yaml +4 -4
- data/lib/nexosis_api/client/sessions.rb +21 -61
- data/nexosisapi.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f9380a789d239e77f6878bd42e9e4dcb2b64d17
|
4
|
+
data.tar.gz: fb52c150b9a2b535d72ec86c742c83f7d3ee1005
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57b071e66f509b18075801b6c017abfb52aa5d4dec29a5b462947009003265618c0cd41294b9cd63e24d6d09ecea57c7baf03a24a74ac40580241515bd9a7d77
|
7
|
+
data.tar.gz: d5504612707b4589fcb9b77d45bdd97f99f8d0ea0e3476cf0e8727b99ab9e29b2373007ff1d2e01f110c97a9da356c7a7038499919669b070273a5676fc18ee3
|
@@ -70,49 +70,20 @@ module NexosisApi
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
-
#
|
73
|
+
# Initiate a new forecast session based on a named dataset.
|
74
74
|
#
|
75
75
|
# @param dataset_name [String] The name of the saved data set that has the data to forecast on.
|
76
76
|
# @param start_date [DateTime] The starting date of the forecast period. Can be ISO 8601 string.
|
77
77
|
# @param end_date [DateTime] The ending date of the forecast period. Can be ISO 8601 string.
|
78
78
|
# @param target_column [String] The name of the column for which you want predictions. Nil if defined in dataset.
|
79
79
|
# @param result_interval [NexosisApi::TimeInterval] (optional) - The date/time interval (e.g. Day, Hour) at which predictions should be generated. So, if Hour is specified for this parameter you will get a Result record for each hour between startDate and endDate. If unspecified, we’ll generate predictions at a Day interval.
|
80
|
+
# @param column_metadata [Array of NexosisApi::DatasetColumn] (optional) - specification for how to handle columns if different from existing metadata on dataset
|
80
81
|
# @return [NexosisApi::SessionResponse] providing information about the sesssion
|
81
82
|
# @note The time interval selected must be greater than or equal to the finest granularity of the data provided.
|
82
83
|
# For instance if your data includes many recoreds per hour, then you could request hour, day, or any other result interval.
|
83
84
|
# However, if your data includes only a few records per day or fewer, then a request for an hourly result interval will produce poor results.
|
84
|
-
def create_forecast_session(dataset_name, start_date, end_date, target_column = nil, result_interval = NexosisApi::TimeInterval::DAY)
|
85
|
-
create_session(dataset_name, start_date, end_date, target_column, false, nil, "forecast",
|
86
|
-
end
|
87
|
-
|
88
|
-
# Forecast from CSV formatted data.
|
89
|
-
#
|
90
|
-
# @param csv [CSV] initialized CSV object ready for reading.
|
91
|
-
# @param start_date [DateTime] The starting date of the forecast period. Can be ISO 8601 parseable string.
|
92
|
-
# @param end_date [DateTime] The ending date of the forecast period. Can be ISO 8601 parseable string.
|
93
|
-
# @param target_column [String] The name of the column for which you want predictions.
|
94
|
-
# @param result_interval [NexosisApi::TimeInterval] (optional) - The date/time interval (e.g. Day, Hour) at which predictions should be generated. So, if Hour is specified for this parameter you will get a Result record for each hour between startDate and endDate. If unspecified, we’ll generate predictions at a Day interval.
|
95
|
-
# @return [NexosisApi::SessionResponse] providing information about the sesssion
|
96
|
-
# @example load and send local file
|
97
|
-
# mycsv = CSV.read('.\mylocal.csv')
|
98
|
-
# NexosisApi.client(:api_key=>mykey).create_forecast_session_csv(mycsv,'sales','01-01-2017','02-01-2017')
|
99
|
-
def create_forecast_session_csv(csv, start_date, end_date, target_column, result_interval = NexosisApi::TimeInterval::DAY)
|
100
|
-
content = process_csv_to_s csv
|
101
|
-
create_session(nil, start_date, end_date, target_column, false, nil, "forecast", content, "text/csv", result_interval)
|
102
|
-
end
|
103
|
-
|
104
|
-
# Forecast from data posted in the request.
|
105
|
-
#
|
106
|
-
# @param json_data [String] Json dataset matching the dataset input schema.
|
107
|
-
# @param start_date [DateTime] The starting date of the forecast period. Can be ISO 8601 string.
|
108
|
-
# @param end_date [DateTime] The ending date of the forecast period. Can be ISO 8601 string.
|
109
|
-
# @param target_column [String] The name of the column for which you want predictions. Nil if defined in dataset
|
110
|
-
# @param result_interval [NexosisApi::TimeInterval] (optional) - The date/time interval (e.g. Day, Hour) at which predictions should be generated. So, if Hour is specified for this parameter you will get a Result record for each hour between startDate and endDate. If unspecified, we’ll generate predictions at a Day interval.
|
111
|
-
# @return [NexosisApi::SessionResponse] providing information about the sesssion
|
112
|
-
# @see https://developers.nexosis.com/docs/services/98847a3fbbe64f73aa959d3cededb3af/operations/5919ef80a730020dd851f233
|
113
|
-
def create_forecast_session_data(json_data, start_date, end_date, target_column = nil, result_interval = NexosisApi::TimeInterval::DAY)
|
114
|
-
json_data = json_data.to_json unless json_data.is_a? String
|
115
|
-
create_session nil, start_date, end_date, target_column, false, nil, "forecast", json_data, "application/json", result_interval
|
85
|
+
def create_forecast_session(dataset_name, start_date, end_date, target_column = nil, result_interval = NexosisApi::TimeInterval::DAY, column_metadata = nil)
|
86
|
+
create_session(dataset_name, start_date, end_date, target_column, false, nil, "forecast", result_interval, column_metadata)
|
116
87
|
end
|
117
88
|
|
118
89
|
# Estimate the cost of a forecast from data already saved to the API.
|
@@ -124,7 +95,7 @@ module NexosisApi
|
|
124
95
|
# @param result_interval [NexosisApi::TimeInterval] (optional) - The date/time interval (e.g. Day, Hour) at which predictions should be generated. So, if Hour is specified for this parameter you will get a Result record for each hour between startDate and endDate. If unspecified, we’ll generate predictions at a Day interval.
|
125
96
|
# @return [NexosisApi::SessionResponse] providing information about the sesssion, including the cost
|
126
97
|
def estimate_forecast_session(dataset_name, start_date, end_date, target_column = nil, result_interval = NexosisApi::TimeInterval::DAY)
|
127
|
-
create_session
|
98
|
+
create_session(dataset_name, start_date, end_date, target_column, true, nil, "forecast", result_interval)
|
128
99
|
end
|
129
100
|
|
130
101
|
# Analyze impact for an event with data already saved to the API.
|
@@ -135,26 +106,12 @@ module NexosisApi
|
|
135
106
|
# @param event_name [String] The name of the event.
|
136
107
|
# @param target_column [String] The name of the column for which you want predictions. Nil if defined in datatset.
|
137
108
|
# @param result_interval [NexosisApi::TimeInterval] (optional) - The date/time interval (e.g. Day, Hour) at which predictions should be generated. So, if Hour is specified for this parameter you will get a Result record for each hour between startDate and endDate. If unspecified, we’ll generate predictions at a Day interval.
|
109
|
+
# @param column_metadata [Array of NexosisApi::DatasetColumn] (optional) - specification for how to handle columns if different from existing metadata on dataset
|
138
110
|
# @return [NexosisApi::SessionResponse] providing information about the sesssion
|
139
|
-
def create_impact_session(dataset_name, start_date, end_date, event_name, target_column = nil, result_interval = NexosisApi::TimeInterval::DAY)
|
140
|
-
create_session
|
111
|
+
def create_impact_session(dataset_name, start_date, end_date, event_name, target_column = nil, result_interval = NexosisApi::TimeInterval::DAY, column_metadata = nil)
|
112
|
+
create_session(dataset_name, start_date, end_date, target_column, false, event_name, "impact", result_interval, column_metadata)
|
141
113
|
end
|
142
114
|
|
143
|
-
# Analyze impact for an event with data in json format.
|
144
|
-
#
|
145
|
-
# @param json_data [String] Json dataset matching the dataset input schema.
|
146
|
-
# @param start_date [DateTime] The starting date of the impactful event. Can be ISO 8601 string.
|
147
|
-
# @param end_date [DateTime] The ending date of the impactful event. Can be ISO 8601 string.
|
148
|
-
# @param event_name [String] The name of the event.
|
149
|
-
# @param target_column [String] The name of the column for which you want predictions. Nil if defined in dataset.
|
150
|
-
# @param result_interval [NexosisApi::TimeInterval] (optional) - The date/time interval (e.g. Day, Hour) at which predictions should be generated. So, if Hour is specified for this parameter you will get a Result record for each hour between startDate and endDate. If unspecified, we’ll generate predictions at a Day interval.
|
151
|
-
# @return [NexosisApi::SessionResponse] providing information about the sesssion
|
152
|
-
# @see https://developers.nexosis.com/docs/services/98847a3fbbe64f73aa959d3cededb3af/operations/5919ef80a730020dd851f233
|
153
|
-
def create_impact_session_data(json_data, start_date, end_date, event_name, target_column = nil, result_interval = NexosisApi::TimeInterval::DAY)
|
154
|
-
json_data = json_data.to_json unless json_data.is_a? String
|
155
|
-
create_session nil, start_date, end_date, target_column, false, event_name, "impact", json_data, "application/json", result_interval
|
156
|
-
end
|
157
|
-
|
158
115
|
# Estimate the cost of impact analysis for an event with data already saved to the API.
|
159
116
|
#
|
160
117
|
# @param dataset_name [String] The name of the saved data set that has the data to forecast on.
|
@@ -164,8 +121,8 @@ module NexosisApi
|
|
164
121
|
# @param target_column [String] The name of the column for which you want predictions. Nil if defined in dataset.
|
165
122
|
# @param result_interval [NexosisApi::TimeInterval] (optional) - The date/time interval (e.g. Day, Hour) at which predictions should be generated. So, if Hour is specified for this parameter you will get a Result record for each hour between startDate and endDate. If unspecified, we’ll generate predictions at a Day interval.
|
166
123
|
# @return [NexosisApi::SessionResponse] providing information about the sesssion, including the cost
|
167
|
-
|
168
|
-
create_session
|
124
|
+
def estimate_impact_session(dataset_name, start_date, end_date, event_name, target_column = nil, result_interval = NexosisApi::TimeInterval::DAY)
|
125
|
+
create_session(dataset_name, start_date, end_date, target_column, true, event_name, "impact", result_interval)
|
169
126
|
end
|
170
127
|
|
171
128
|
# Get the results of the session.
|
@@ -178,7 +135,7 @@ module NexosisApi
|
|
178
135
|
|
179
136
|
if as_csv
|
180
137
|
@headers["Accept"] = "text/csv"
|
181
|
-
|
138
|
+
end
|
182
139
|
response = self.class.get(session_result_url, @options)
|
183
140
|
@headers.delete("Accept")
|
184
141
|
|
@@ -207,7 +164,7 @@ module NexosisApi
|
|
207
164
|
end
|
208
165
|
end
|
209
166
|
private
|
210
|
-
def create_session(dataset_name, start_date, end_date, target_column = nil, is_estimate=false, event_name = nil, type = "forecast",
|
167
|
+
def create_session(dataset_name, start_date, end_date, target_column = nil, is_estimate=false, event_name = nil, type = "forecast", result_interval = NexosisApi::TimeInterval::DAY, column_metadata = nil)
|
211
168
|
session_url = "/sessions/#{type}"
|
212
169
|
query = {
|
213
170
|
"targetColumn" => target_column.to_s,
|
@@ -220,12 +177,15 @@ module NexosisApi
|
|
220
177
|
if(event_name.nil? == false)
|
221
178
|
query["eventName"] = event_name
|
222
179
|
end
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
180
|
+
body = ''
|
181
|
+
if(column_metadata.nil? == false)
|
182
|
+
column_json = DatasetColumn.to_json(column_metadata)
|
183
|
+
body = {
|
184
|
+
"dataSetName" => dataset_name,
|
185
|
+
"columns" => column_json
|
186
|
+
}
|
187
|
+
end
|
188
|
+
response = self.class.post(session_url, :headers => @headers, :query => query, :body => body.to_json)
|
229
189
|
if(response.success?)
|
230
190
|
session_hash = {"session" => response.parsed_response}.merge(response.headers)
|
231
191
|
NexosisApi::SessionResponse.new(session_hash)
|
data/nexosisapi.gemspec
CHANGED
@@ -16,6 +16,6 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.require_paths = ['lib']
|
17
17
|
spec.required_ruby_version = '>= 2.0.0'
|
18
18
|
spec.summary = "Ruby client for working with the Nexosis API"
|
19
|
-
spec.version = '1.0
|
19
|
+
spec.version = '1.1.0'
|
20
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.0
|
4
|
+
version: 1.1.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-07-
|
11
|
+
date: 2017-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|