nexosis_api 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/lib/nexosis_api/algorithm.rb +22 -22
  3. data/lib/nexosis_api/algorithm_contestant.rb +43 -43
  4. data/lib/nexosis_api/calendar_jointarget.rb +35 -35
  5. data/lib/nexosis_api/classifier_result.rb +25 -25
  6. data/lib/nexosis_api/client/contest.rb +66 -66
  7. data/lib/nexosis_api/client/datasets.rb +155 -155
  8. data/lib/nexosis_api/client/imports.rb +141 -141
  9. data/lib/nexosis_api/client/models.rb +108 -108
  10. data/lib/nexosis_api/client/sessions.rb +213 -213
  11. data/lib/nexosis_api/client/views.rb +105 -105
  12. data/lib/nexosis_api/client.rb +118 -118
  13. data/lib/nexosis_api/column.rb +50 -50
  14. data/lib/nexosis_api/column_options.rb +38 -38
  15. data/lib/nexosis_api/column_role.rb +19 -19
  16. data/lib/nexosis_api/column_type.rb +23 -19
  17. data/lib/nexosis_api/dataset_data.rb +22 -22
  18. data/lib/nexosis_api/dataset_jointarget.rb +18 -18
  19. data/lib/nexosis_api/dataset_model.rb +26 -26
  20. data/lib/nexosis_api/dataset_summary.rb +33 -33
  21. data/lib/nexosis_api/http_exception.rb +28 -28
  22. data/lib/nexosis_api/impact_metric.rb +22 -22
  23. data/lib/nexosis_api/imports_response.rb +74 -79
  24. data/lib/nexosis_api/join.rb +63 -63
  25. data/lib/nexosis_api/link.rb +18 -18
  26. data/lib/nexosis_api/message.rb +19 -19
  27. data/lib/nexosis_api/metric.rb +16 -16
  28. data/lib/nexosis_api/model_summary.rb +66 -66
  29. data/lib/nexosis_api/paged_array.rb +35 -35
  30. data/lib/nexosis_api/predict_response.rb +35 -35
  31. data/lib/nexosis_api/session.rb +118 -118
  32. data/lib/nexosis_api/session_contest.rb +30 -30
  33. data/lib/nexosis_api/session_response.rb +33 -33
  34. data/lib/nexosis_api/session_result.rb +27 -27
  35. data/lib/nexosis_api/session_selection_metrics.rb +20 -20
  36. data/lib/nexosis_api/time_interval.rb +15 -15
  37. data/lib/nexosis_api/view_data.rb +14 -14
  38. data/lib/nexosis_api/view_definition.rb +64 -64
  39. data/lib/nexosis_api.rb +11 -11
  40. data/nexosisapi.gemspec +20 -20
  41. metadata +3 -3
@@ -1,108 +1,108 @@
1
- module NexosisApi
2
- class Client
3
- # class to operate on model endpoint in Nexosis API
4
- # @since 1.3.0
5
- module Models
6
- # List all models created in your company, optionally filtered by query parameters
7
- #
8
- # @param datasource_name [String] optionally limit to those
9
- # models created for this data source name.
10
- # @param query_options [Hash] limit by dates: begin_date and/or end_date
11
- # @note - query options dates can either be ISO 8601 compliant strings or Date objects
12
- # @return [NexosisApi::PagedArray of NexosisApi::ModelSummary] - all models available within the query parameters
13
- def list_models(datasource_name = nil, page = 0, page_size = 50, query_options = {})
14
- model_url = '/models'
15
- query = {
16
- page: page,
17
- pageSize: page_size
18
- }
19
- unless query_options.empty?
20
- query.store('createdBeforeDate', query_options['end_date']) unless query_options['end_date'].nil?
21
- query.store('createdAfterDate', query_options['begin_date']) unless query_options['begin_date'].nil?
22
- end
23
- query.store(dataSourceName: datasource_name) unless datasource_name.nil?
24
- response = self.class.get(model_url, headers: @headers, query: query)
25
- raise HttpException.new("There was a problem listing models: #{response.code}.",
26
- "listing models with data source name #{datasource_name}",
27
- response) unless response.success?
28
- NexosisApi::PagedArray.new(response.parsed_response,
29
- response.parsed_response['items']
30
- .map { |item| NexosisApi::ModelSummary.new(item) })
31
- end
32
-
33
- # Get the details of the particular model requested by id
34
- #
35
- # @param model_id [String] The unique identifier for the model returned by a create-model session
36
- # @return [NexosisApi::ModelSummary]
37
- def get_model(model_id)
38
- raise ArgumentError, 'Retrieving a model requires that model_id be specified and it is currently null.' if model_id.nil?
39
- model_url = "/models/#{model_id}"
40
- response = self.class.get(model_url, @options)
41
- if (response.success?)
42
- NexosisApi::ModelSummary.new(response.parsed_response)
43
- else
44
- raise HttpException.new("There was a problem getting your model: #{response.code}.", "Could not get model #{model_id}", response)
45
- end
46
- end
47
-
48
- # Run a feature set through the model to get predictions
49
- #
50
- # @param model_id [String] unique identifier of model to use
51
- # @param feature_data [Array of Hash] feature columns with values to predict from
52
- # @return [NexosisApi::PredictResponse]
53
- # @note The feature data shape should match that of the dataset used to create the model.
54
- # Any missing features in this request will reduce the quality of the predictions.
55
- def predict(model_id, feature_data)
56
- raise ArgumentError, 'Running predictions requires that model_id be specified and it is currently empty.' if model_id.empty?
57
- raise ArgumentError, 'Running predictions requires that feature_data be specified and it is currently empty.' if feature_data.empty?
58
- predict_url = "/models/#{model_id}/predict"
59
- response = self.class.post(predict_url, headers: @headers, body: { "data": feature_data }.to_json)
60
- if (response.success?)
61
- NexosisApi::PredictResponse.new(model_id, response.parsed_response)
62
- else
63
- raise HttpException.new("There was a problem predicting from your model: #{response.code}.",
64
- "Could not start predict for #{model_id}",
65
- response)
66
- end
67
- end
68
-
69
- # Remove an existing model
70
- #
71
- # @param model_id [String] the unique id of the model to remove.
72
- def remove_model(model_id)
73
- raise ArgumentError, 'Deleting a model requires that model_id be specified and it is currently empty.' if model_id.empty?
74
- delete_url = "/models/#{model_id}"
75
- response = self.class.delete(delete_url, @options)
76
- unless (response.success?)
77
- raise HttpException.new("There was a problem deleting your model: #{response.code}.",
78
- "Could not delete #{model_id}",
79
- response)
80
- end
81
- end
82
-
83
- # Deletes multiple models based on the provided filter criteria.
84
- # @param datasource_name [String] remove all models created by this datasource
85
- # @param begin_date [DateTime] remove all models created after this date/time - inclusive. May be a ISO 8601 compliant string.
86
- # @param end_date [DateTime] remove all models created before this date/time - inclusive. May be a ISO 8601 compliant string.
87
- # @note - Use with great care. This permanently removes trained models.
88
- # All parameters are indepdently optional, but one must be sent.
89
- def remove_models(datasource_name = nil, begin_date = nil, end_date = nil)
90
- params_unset = datasource_name.nil?
91
- params_unset &= begin_date.nil?
92
- params_unset &= end_date.nil?
93
- raise ArgumentError, 'Must set one of the method parameters.' if params_unset
94
- delete_url = '/models'
95
- query = {}
96
- query.store('dataSourceName', datasource_name) unless datasource_name.nil?
97
- query.store('createdAfterDate', begin_date) unless begin_date.nil?
98
- query.store('createdBeforeDate', end_date) unless end_date.nil?
99
- response = self.class.delete(delete_url, headers: @headers, query: query)
100
- unless (response.success?)
101
- raise HttpException.new("There was a problem deleting your models: #{response.code}.",
102
- 'Could not delete models',
103
- response)
104
- end
105
- end
106
- end
107
- end
108
- end
1
+ module NexosisApi
2
+ class Client
3
+ # class to operate on model endpoint in Nexosis API
4
+ # @since 1.3.0
5
+ module Models
6
+ # List all models created in your company, optionally filtered by query parameters
7
+ #
8
+ # @param datasource_name [String] optionally limit to those
9
+ # models created for this data source name.
10
+ # @param query_options [Hash] limit by dates: begin_date and/or end_date
11
+ # @note - query options dates can either be ISO 8601 compliant strings or Date objects
12
+ # @return [NexosisApi::PagedArray of NexosisApi::ModelSummary] - all models available within the query parameters
13
+ def list_models(datasource_name = nil, page = 0, page_size = 50, query_options = {})
14
+ model_url = '/models'
15
+ query = {
16
+ page: page,
17
+ pageSize: page_size
18
+ }
19
+ unless query_options.empty?
20
+ query.store('createdBeforeDate', query_options['end_date']) unless query_options['end_date'].nil?
21
+ query.store('createdAfterDate', query_options['begin_date']) unless query_options['begin_date'].nil?
22
+ end
23
+ query.store(dataSourceName: datasource_name) unless datasource_name.nil?
24
+ response = self.class.get(model_url, headers: @headers, query: query)
25
+ raise HttpException.new("There was a problem listing models: #{response.code}.",
26
+ "listing models with data source name #{datasource_name}",
27
+ response) unless response.success?
28
+ NexosisApi::PagedArray.new(response.parsed_response,
29
+ response.parsed_response['items']
30
+ .map { |item| NexosisApi::ModelSummary.new(item) })
31
+ end
32
+
33
+ # Get the details of the particular model requested by id
34
+ #
35
+ # @param model_id [String] The unique identifier for the model returned by a create-model session
36
+ # @return [NexosisApi::ModelSummary]
37
+ def get_model(model_id)
38
+ raise ArgumentError, 'Retrieving a model requires that model_id be specified and it is currently null.' if model_id.nil?
39
+ model_url = "/models/#{model_id}"
40
+ response = self.class.get(model_url, @options)
41
+ if (response.success?)
42
+ NexosisApi::ModelSummary.new(response.parsed_response)
43
+ else
44
+ raise HttpException.new("There was a problem getting your model: #{response.code}.", "Could not get model #{model_id}", response)
45
+ end
46
+ end
47
+
48
+ # Run a feature set through the model to get predictions
49
+ #
50
+ # @param model_id [String] unique identifier of model to use
51
+ # @param feature_data [Array of Hash] feature columns with values to predict from
52
+ # @return [NexosisApi::PredictResponse]
53
+ # @note The feature data shape should match that of the dataset used to create the model.
54
+ # Any missing features in this request will reduce the quality of the predictions.
55
+ def predict(model_id, feature_data)
56
+ raise ArgumentError, 'Running predictions requires that model_id be specified and it is currently empty.' if model_id.empty?
57
+ raise ArgumentError, 'Running predictions requires that feature_data be specified and it is currently empty.' if feature_data.empty?
58
+ predict_url = "/models/#{model_id}/predict"
59
+ response = self.class.post(predict_url, headers: @headers, body: { "data": feature_data }.to_json)
60
+ if (response.success?)
61
+ NexosisApi::PredictResponse.new(model_id, response.parsed_response)
62
+ else
63
+ raise HttpException.new("There was a problem predicting from your model: #{response.code}.",
64
+ "Could not start predict for #{model_id}",
65
+ response)
66
+ end
67
+ end
68
+
69
+ # Remove an existing model
70
+ #
71
+ # @param model_id [String] the unique id of the model to remove.
72
+ def remove_model(model_id)
73
+ raise ArgumentError, 'Deleting a model requires that model_id be specified and it is currently empty.' if model_id.empty?
74
+ delete_url = "/models/#{model_id}"
75
+ response = self.class.delete(delete_url, @options)
76
+ unless (response.success?)
77
+ raise HttpException.new("There was a problem deleting your model: #{response.code}.",
78
+ "Could not delete #{model_id}",
79
+ response)
80
+ end
81
+ end
82
+
83
+ # Deletes multiple models based on the provided filter criteria.
84
+ # @param datasource_name [String] remove all models created by this datasource
85
+ # @param begin_date [DateTime] remove all models created after this date/time - inclusive. May be a ISO 8601 compliant string.
86
+ # @param end_date [DateTime] remove all models created before this date/time - inclusive. May be a ISO 8601 compliant string.
87
+ # @note - Use with great care. This permanently removes trained models.
88
+ # All parameters are indepdently optional, but one must be sent.
89
+ def remove_models(datasource_name = nil, begin_date = nil, end_date = nil)
90
+ params_unset = datasource_name.nil?
91
+ params_unset &= begin_date.nil?
92
+ params_unset &= end_date.nil?
93
+ raise ArgumentError, 'Must set one of the method parameters.' if params_unset
94
+ delete_url = '/models'
95
+ query = {}
96
+ query.store('dataSourceName', datasource_name) unless datasource_name.nil?
97
+ query.store('createdAfterDate', begin_date) unless begin_date.nil?
98
+ query.store('createdBeforeDate', end_date) unless end_date.nil?
99
+ response = self.class.delete(delete_url, headers: @headers, query: query)
100
+ unless (response.success?)
101
+ raise HttpException.new("There was a problem deleting your models: #{response.code}.",
102
+ 'Could not delete models',
103
+ response)
104
+ end
105
+ end
106
+ end
107
+ end
108
+ end