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.
- checksums.yaml +4 -4
- data/lib/nexosis_api/algorithm.rb +22 -22
- data/lib/nexosis_api/algorithm_contestant.rb +43 -43
- data/lib/nexosis_api/calendar_jointarget.rb +35 -35
- data/lib/nexosis_api/classifier_result.rb +25 -25
- data/lib/nexosis_api/client/contest.rb +66 -66
- data/lib/nexosis_api/client/datasets.rb +155 -155
- data/lib/nexosis_api/client/imports.rb +141 -141
- data/lib/nexosis_api/client/models.rb +108 -108
- data/lib/nexosis_api/client/sessions.rb +213 -213
- data/lib/nexosis_api/client/views.rb +105 -105
- data/lib/nexosis_api/client.rb +118 -118
- data/lib/nexosis_api/column.rb +50 -50
- data/lib/nexosis_api/column_options.rb +38 -38
- data/lib/nexosis_api/column_role.rb +19 -19
- data/lib/nexosis_api/column_type.rb +23 -19
- data/lib/nexosis_api/dataset_data.rb +22 -22
- data/lib/nexosis_api/dataset_jointarget.rb +18 -18
- data/lib/nexosis_api/dataset_model.rb +26 -26
- data/lib/nexosis_api/dataset_summary.rb +33 -33
- data/lib/nexosis_api/http_exception.rb +28 -28
- data/lib/nexosis_api/impact_metric.rb +22 -22
- data/lib/nexosis_api/imports_response.rb +74 -79
- data/lib/nexosis_api/join.rb +63 -63
- data/lib/nexosis_api/link.rb +18 -18
- data/lib/nexosis_api/message.rb +19 -19
- data/lib/nexosis_api/metric.rb +16 -16
- data/lib/nexosis_api/model_summary.rb +66 -66
- data/lib/nexosis_api/paged_array.rb +35 -35
- data/lib/nexosis_api/predict_response.rb +35 -35
- data/lib/nexosis_api/session.rb +118 -118
- data/lib/nexosis_api/session_contest.rb +30 -30
- data/lib/nexosis_api/session_response.rb +33 -33
- data/lib/nexosis_api/session_result.rb +27 -27
- data/lib/nexosis_api/session_selection_metrics.rb +20 -20
- data/lib/nexosis_api/time_interval.rb +15 -15
- data/lib/nexosis_api/view_data.rb +14 -14
- data/lib/nexosis_api/view_definition.rb +64 -64
- data/lib/nexosis_api.rb +11 -11
- data/nexosisapi.gemspec +20 -20
- metadata +3 -3
data/lib/nexosis_api/join.rb
CHANGED
@@ -1,63 +1,63 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module NexosisApi
|
4
|
-
# class to hold a join defintion initialized by a hash of join values
|
5
|
-
# @since 1.2.0
|
6
|
-
class Join
|
7
|
-
def initialize(join_hash)
|
8
|
-
join_hash.each do |k, v|
|
9
|
-
if k == 'dataSet'
|
10
|
-
@join_target = NexosisApi::DatasetJoinTarget.new(v) unless v.nil?
|
11
|
-
elsif k == 'calendar'
|
12
|
-
@join_target = NexosisApi::CalendarJoinTarget.new(v) unless v.nil?
|
13
|
-
elsif k == 'columnOptions'
|
14
|
-
next if v.nil?
|
15
|
-
@column_options = v.map do |key, option|
|
16
|
-
NexosisApi::ColumnOptions.new(key, option)
|
17
|
-
end
|
18
|
-
elsif k == 'joins'
|
19
|
-
next if v.nil?
|
20
|
-
@joins = v.map do |join|
|
21
|
-
NexosisApi::Join.new(join)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
# The details of the data source that will be participating in the join
|
28
|
-
# @return [Object] details of the join target
|
29
|
-
attr_accessor :join_target
|
30
|
-
|
31
|
-
# The optional column definition for the join which
|
32
|
-
# defines how columns should be used from the joined dataset
|
33
|
-
# @return [Array of NexosisApi::ColumnOptions] column options definition
|
34
|
-
attr_accessor :column_options
|
35
|
-
|
36
|
-
# Optional additional data source to be joined to this data source
|
37
|
-
# @return [Array of NexosisApi::Join] zero or more additional joins
|
38
|
-
attr_accessor :joins
|
39
|
-
|
40
|
-
# provides a custom hash which can be converted to json matching api request
|
41
|
-
def to_hash
|
42
|
-
hash = join_target.to_hash
|
43
|
-
if column_options.nil? == false
|
44
|
-
hash['columnOptions'] = {}
|
45
|
-
column_options.each do |column|
|
46
|
-
hash['columnOptions'].merge!(column.to_hash)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
if joins.nil? == false
|
50
|
-
hash['joins'] = []
|
51
|
-
joins.each do |join|
|
52
|
-
hash['joins'] << join.to_hash
|
53
|
-
end
|
54
|
-
end
|
55
|
-
hash
|
56
|
-
end
|
57
|
-
|
58
|
-
# gets a json represenation which can be used in api request
|
59
|
-
def to_json
|
60
|
-
to_hash.to_json
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module NexosisApi
|
4
|
+
# class to hold a join defintion initialized by a hash of join values
|
5
|
+
# @since 1.2.0
|
6
|
+
class Join
|
7
|
+
def initialize(join_hash)
|
8
|
+
join_hash.each do |k, v|
|
9
|
+
if k == 'dataSet'
|
10
|
+
@join_target = NexosisApi::DatasetJoinTarget.new(v) unless v.nil?
|
11
|
+
elsif k == 'calendar'
|
12
|
+
@join_target = NexosisApi::CalendarJoinTarget.new(v) unless v.nil?
|
13
|
+
elsif k == 'columnOptions'
|
14
|
+
next if v.nil?
|
15
|
+
@column_options = v.map do |key, option|
|
16
|
+
NexosisApi::ColumnOptions.new(key, option)
|
17
|
+
end
|
18
|
+
elsif k == 'joins'
|
19
|
+
next if v.nil?
|
20
|
+
@joins = v.map do |join|
|
21
|
+
NexosisApi::Join.new(join)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# The details of the data source that will be participating in the join
|
28
|
+
# @return [Object] details of the join target
|
29
|
+
attr_accessor :join_target
|
30
|
+
|
31
|
+
# The optional column definition for the join which
|
32
|
+
# defines how columns should be used from the joined dataset
|
33
|
+
# @return [Array of NexosisApi::ColumnOptions] column options definition
|
34
|
+
attr_accessor :column_options
|
35
|
+
|
36
|
+
# Optional additional data source to be joined to this data source
|
37
|
+
# @return [Array of NexosisApi::Join] zero or more additional joins
|
38
|
+
attr_accessor :joins
|
39
|
+
|
40
|
+
# provides a custom hash which can be converted to json matching api request
|
41
|
+
def to_hash
|
42
|
+
hash = join_target.to_hash
|
43
|
+
if column_options.nil? == false
|
44
|
+
hash['columnOptions'] = {}
|
45
|
+
column_options.each do |column|
|
46
|
+
hash['columnOptions'].merge!(column.to_hash)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
if joins.nil? == false
|
50
|
+
hash['joins'] = []
|
51
|
+
joins.each do |join|
|
52
|
+
hash['joins'] << join.to_hash
|
53
|
+
end
|
54
|
+
end
|
55
|
+
hash
|
56
|
+
end
|
57
|
+
|
58
|
+
# gets a json represenation which can be used in api request
|
59
|
+
def to_json
|
60
|
+
to_hash.to_json
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/lib/nexosis_api/link.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
module NexosisApi
|
2
|
-
# Class to parse hypermedia resutls
|
3
|
-
class Link
|
4
|
-
def initialize(link_hash)
|
5
|
-
link_hash.each do |k, v|
|
6
|
-
instance_variable_set("@#{k}", v) unless v.nil?
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
# relation type of the link
|
11
|
-
# @return [String]
|
12
|
-
attr_accessor :rel
|
13
|
-
|
14
|
-
# resource url
|
15
|
-
# @return [String]
|
16
|
-
attr_accessor :href
|
17
|
-
end
|
18
|
-
end
|
1
|
+
module NexosisApi
|
2
|
+
# Class to parse hypermedia resutls
|
3
|
+
class Link
|
4
|
+
def initialize(link_hash)
|
5
|
+
link_hash.each do |k, v|
|
6
|
+
instance_variable_set("@#{k}", v) unless v.nil?
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
# relation type of the link
|
11
|
+
# @return [String]
|
12
|
+
attr_accessor :rel
|
13
|
+
|
14
|
+
# resource url
|
15
|
+
# @return [String]
|
16
|
+
attr_accessor :href
|
17
|
+
end
|
18
|
+
end
|
data/lib/nexosis_api/message.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
module NexosisApi
|
2
|
-
# class to provide message responses
|
3
|
-
# @since 1.4.1
|
4
|
-
class Message
|
5
|
-
def initialize(message_hash)
|
6
|
-
message_hash.each do |k,v|
|
7
|
-
instance_variable_set("@#{k}", v) unless v.nil?
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
# The type of message: information, warning, or error
|
12
|
-
# @return [String]
|
13
|
-
attr_accessor :severity
|
14
|
-
|
15
|
-
# The content of the message
|
16
|
-
# @return [String]
|
17
|
-
attr_accessor :message
|
18
|
-
end
|
19
|
-
end
|
1
|
+
module NexosisApi
|
2
|
+
# class to provide message responses
|
3
|
+
# @since 1.4.1
|
4
|
+
class Message
|
5
|
+
def initialize(message_hash)
|
6
|
+
message_hash.each do |k,v|
|
7
|
+
instance_variable_set("@#{k}", v) unless v.nil?
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
# The type of message: information, warning, or error
|
12
|
+
# @return [String]
|
13
|
+
attr_accessor :severity
|
14
|
+
|
15
|
+
# The content of the message
|
16
|
+
# @return [String]
|
17
|
+
attr_accessor :message
|
18
|
+
end
|
19
|
+
end
|
data/lib/nexosis_api/metric.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
module NexosisApi
|
2
|
-
# Class to parse algorithm metrics from model results
|
3
|
-
class Metric
|
4
|
-
def initialize(name, value)
|
5
|
-
@name = name
|
6
|
-
@value = value
|
7
|
-
end
|
8
|
-
|
9
|
-
# Friendly name of the metric
|
10
|
-
# @return [String]
|
11
|
-
attr_accessor :name
|
12
|
-
|
13
|
-
# Calculated metric
|
14
|
-
# @return [Float]
|
15
|
-
attr_accessor :value
|
16
|
-
end
|
1
|
+
module NexosisApi
|
2
|
+
# Class to parse algorithm metrics from model results
|
3
|
+
class Metric
|
4
|
+
def initialize(name, value)
|
5
|
+
@name = name
|
6
|
+
@value = value
|
7
|
+
end
|
8
|
+
|
9
|
+
# Friendly name of the metric
|
10
|
+
# @return [String]
|
11
|
+
attr_accessor :name
|
12
|
+
|
13
|
+
# Calculated metric
|
14
|
+
# @return [Float]
|
15
|
+
attr_accessor :value
|
16
|
+
end
|
17
17
|
end
|
@@ -1,66 +1,66 @@
|
|
1
|
-
module NexosisApi
|
2
|
-
# class to hold the parsed results of model summary json
|
3
|
-
# @since 1.3.0
|
4
|
-
class ModelSummary
|
5
|
-
def initialize(model_hash)
|
6
|
-
model_hash.each do |k, v|
|
7
|
-
k = k.to_s
|
8
|
-
if (k == 'modelId')
|
9
|
-
@model_id = v
|
10
|
-
elsif (k == 'predictionDomain')
|
11
|
-
@prediction_domain = v
|
12
|
-
elsif (k == 'dataSourceName')
|
13
|
-
@datasource_name = v
|
14
|
-
elsif (k == 'createdDate')
|
15
|
-
@created_date = DateTime.parse(v) unless v.nil?
|
16
|
-
elsif (k == 'algorithm')
|
17
|
-
@algorithm = NexosisApi::Algorithm.new(v) unless v.nil?
|
18
|
-
elsif (k == 'columns')
|
19
|
-
@column_metadata = v.reject { |_key, value| value.nil? }
|
20
|
-
.map do |col_key, col_val|
|
21
|
-
NexosisApi::Column.new(col_key, col_val)
|
22
|
-
end
|
23
|
-
elsif (k == 'metrics')
|
24
|
-
@metrics = v.reject { |_key, value| value.nil? }
|
25
|
-
.map do |col_key, col_val|
|
26
|
-
NexosisApi::Metric.new(col_key, col_val)
|
27
|
-
end
|
28
|
-
elsif (k == 'sessionId')
|
29
|
-
@session_id = v
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
# Unique model id for this model in uuid/guid format.
|
35
|
-
# @return [String]
|
36
|
-
attr_accessor :model_id
|
37
|
-
|
38
|
-
# Unique id of the session used to create this model instance
|
39
|
-
# @return [String]
|
40
|
-
attr_accessor :session_id
|
41
|
-
|
42
|
-
# The type of prediction performed
|
43
|
-
# @return [String]
|
44
|
-
attr_reader :prediction_domain
|
45
|
-
|
46
|
-
# The data source used to create this model
|
47
|
-
# @return [String]
|
48
|
-
attr_accessor :datasource_name
|
49
|
-
|
50
|
-
# The date on which this model was created.
|
51
|
-
# @return [DateTime]
|
52
|
-
attr_accessor :created_date
|
53
|
-
|
54
|
-
# Information about the algorithm used to create the model
|
55
|
-
# @return [NexosisApi::Algorithm]
|
56
|
-
attr_accessor :algorithm
|
57
|
-
|
58
|
-
# Descriptive information about the columns
|
59
|
-
# @return [Array of NexosisApi::Column]
|
60
|
-
attr_accessor :column_metadata
|
61
|
-
|
62
|
-
# Algorithm and model specific metrics which may be of interest
|
63
|
-
# @return [Array of NexosisApi::Metric]
|
64
|
-
attr_accessor :metrics
|
65
|
-
end
|
66
|
-
end
|
1
|
+
module NexosisApi
|
2
|
+
# class to hold the parsed results of model summary json
|
3
|
+
# @since 1.3.0
|
4
|
+
class ModelSummary
|
5
|
+
def initialize(model_hash)
|
6
|
+
model_hash.each do |k, v|
|
7
|
+
k = k.to_s
|
8
|
+
if (k == 'modelId')
|
9
|
+
@model_id = v
|
10
|
+
elsif (k == 'predictionDomain')
|
11
|
+
@prediction_domain = v
|
12
|
+
elsif (k == 'dataSourceName')
|
13
|
+
@datasource_name = v
|
14
|
+
elsif (k == 'createdDate')
|
15
|
+
@created_date = DateTime.parse(v) unless v.nil?
|
16
|
+
elsif (k == 'algorithm')
|
17
|
+
@algorithm = NexosisApi::Algorithm.new(v) unless v.nil?
|
18
|
+
elsif (k == 'columns')
|
19
|
+
@column_metadata = v.reject { |_key, value| value.nil? }
|
20
|
+
.map do |col_key, col_val|
|
21
|
+
NexosisApi::Column.new(col_key, col_val)
|
22
|
+
end
|
23
|
+
elsif (k == 'metrics')
|
24
|
+
@metrics = v.reject { |_key, value| value.nil? }
|
25
|
+
.map do |col_key, col_val|
|
26
|
+
NexosisApi::Metric.new(col_key, col_val)
|
27
|
+
end
|
28
|
+
elsif (k == 'sessionId')
|
29
|
+
@session_id = v
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# Unique model id for this model in uuid/guid format.
|
35
|
+
# @return [String]
|
36
|
+
attr_accessor :model_id
|
37
|
+
|
38
|
+
# Unique id of the session used to create this model instance
|
39
|
+
# @return [String]
|
40
|
+
attr_accessor :session_id
|
41
|
+
|
42
|
+
# The type of prediction performed
|
43
|
+
# @return [String]
|
44
|
+
attr_reader :prediction_domain
|
45
|
+
|
46
|
+
# The data source used to create this model
|
47
|
+
# @return [String]
|
48
|
+
attr_accessor :datasource_name
|
49
|
+
|
50
|
+
# The date on which this model was created.
|
51
|
+
# @return [DateTime]
|
52
|
+
attr_accessor :created_date
|
53
|
+
|
54
|
+
# Information about the algorithm used to create the model
|
55
|
+
# @return [NexosisApi::Algorithm]
|
56
|
+
attr_accessor :algorithm
|
57
|
+
|
58
|
+
# Descriptive information about the columns
|
59
|
+
# @return [Array of NexosisApi::Column]
|
60
|
+
attr_accessor :column_metadata
|
61
|
+
|
62
|
+
# Algorithm and model specific metrics which may be of interest
|
63
|
+
# @return [Array of NexosisApi::Metric]
|
64
|
+
attr_accessor :metrics
|
65
|
+
end
|
66
|
+
end
|
@@ -1,35 +1,35 @@
|
|
1
|
-
module NexosisApi
|
2
|
-
# Generic list base class for list responses
|
3
|
-
# @since 1.4.0
|
4
|
-
class PagedArray < Array
|
5
|
-
def initialize(paged_response, item_array = [])
|
6
|
-
self[0..item_array.length] = item_array
|
7
|
-
var_map = { 'pageNumber' => :@page_number,
|
8
|
-
'totalPages' => :@total_pages,
|
9
|
-
'pageSize' => :@page_size,
|
10
|
-
'totalCount' => :@item_total }
|
11
|
-
paged_response.each { |k, v| instance_variable_set(var_map[k.to_s], v) unless var_map[k.to_s].nil? }
|
12
|
-
@links = paged_response['links'].map { |l| NexosisApi::Link.new(l) } unless paged_response['links'].nil?
|
13
|
-
end
|
14
|
-
|
15
|
-
# The current page number represented by this collection
|
16
|
-
# @return [int]
|
17
|
-
attr_accessor :page_number
|
18
|
-
|
19
|
-
# The total number of pages given the current page size and item total
|
20
|
-
# @return [int]
|
21
|
-
attr_accessor :total_pages
|
22
|
-
|
23
|
-
# The total number of items per page
|
24
|
-
# @return [int]
|
25
|
-
attr_accessor :page_size
|
26
|
-
|
27
|
-
# The total number of items available on the server for this collection
|
28
|
-
# @return [int]
|
29
|
-
attr_accessor :item_total
|
30
|
-
|
31
|
-
# paging links to first, last pages
|
32
|
-
# @return [Array of NexosisApi::Link]
|
33
|
-
attr_accessor :links
|
34
|
-
end
|
35
|
-
end
|
1
|
+
module NexosisApi
|
2
|
+
# Generic list base class for list responses
|
3
|
+
# @since 1.4.0
|
4
|
+
class PagedArray < Array
|
5
|
+
def initialize(paged_response, item_array = [])
|
6
|
+
self[0..item_array.length] = item_array
|
7
|
+
var_map = { 'pageNumber' => :@page_number,
|
8
|
+
'totalPages' => :@total_pages,
|
9
|
+
'pageSize' => :@page_size,
|
10
|
+
'totalCount' => :@item_total }
|
11
|
+
paged_response.each { |k, v| instance_variable_set(var_map[k.to_s], v) unless var_map[k.to_s].nil? }
|
12
|
+
@links = paged_response['links'].map { |l| NexosisApi::Link.new(l) } unless paged_response['links'].nil?
|
13
|
+
end
|
14
|
+
|
15
|
+
# The current page number represented by this collection
|
16
|
+
# @return [int]
|
17
|
+
attr_accessor :page_number
|
18
|
+
|
19
|
+
# The total number of pages given the current page size and item total
|
20
|
+
# @return [int]
|
21
|
+
attr_accessor :total_pages
|
22
|
+
|
23
|
+
# The total number of items per page
|
24
|
+
# @return [int]
|
25
|
+
attr_accessor :page_size
|
26
|
+
|
27
|
+
# The total number of items available on the server for this collection
|
28
|
+
# @return [int]
|
29
|
+
attr_accessor :item_total
|
30
|
+
|
31
|
+
# paging links to first, last pages
|
32
|
+
# @return [Array of NexosisApi::Link]
|
33
|
+
attr_accessor :links
|
34
|
+
end
|
35
|
+
end
|
@@ -1,35 +1,35 @@
|
|
1
|
-
module NexosisApi
|
2
|
-
# Class to hold the parsed response of a prediction request
|
3
|
-
# @since 1.3.0
|
4
|
-
class PredictResponse
|
5
|
-
def initialize(model_id, response_hash)
|
6
|
-
@model_id = model_id
|
7
|
-
@predictions = response_hash['data']
|
8
|
-
@message = response_hash['messages']
|
9
|
-
end
|
10
|
-
|
11
|
-
# The unique identifier for the model used to create these predictions
|
12
|
-
# @return [String]
|
13
|
-
attr_reader :model_id
|
14
|
-
|
15
|
-
# The feature data along with predicted target value
|
16
|
-
# @return [Array of Hash] each row of data as a hash in an array of values
|
17
|
-
# @note The result data includes an echo of the data sent to the predict request
|
18
|
-
# along with the target column containing the values predicted.
|
19
|
-
# [
|
20
|
-
# {
|
21
|
-
# "feature1": 23.33,
|
22
|
-
# "target": 2.59
|
23
|
-
# },
|
24
|
-
# {
|
25
|
-
# "feature1": 15.82,
|
26
|
-
# "target": 1.75
|
27
|
-
# }
|
28
|
-
# ]
|
29
|
-
attr_accessor :predictions
|
30
|
-
|
31
|
-
# A list of warning message optionally returned from prediction run
|
32
|
-
# @return [Array]
|
33
|
-
attr_accessor :messages
|
34
|
-
end
|
35
|
-
end
|
1
|
+
module NexosisApi
|
2
|
+
# Class to hold the parsed response of a prediction request
|
3
|
+
# @since 1.3.0
|
4
|
+
class PredictResponse
|
5
|
+
def initialize(model_id, response_hash)
|
6
|
+
@model_id = model_id
|
7
|
+
@predictions = response_hash['data']
|
8
|
+
@message = response_hash['messages']
|
9
|
+
end
|
10
|
+
|
11
|
+
# The unique identifier for the model used to create these predictions
|
12
|
+
# @return [String]
|
13
|
+
attr_reader :model_id
|
14
|
+
|
15
|
+
# The feature data along with predicted target value
|
16
|
+
# @return [Array of Hash] each row of data as a hash in an array of values
|
17
|
+
# @note The result data includes an echo of the data sent to the predict request
|
18
|
+
# along with the target column containing the values predicted.
|
19
|
+
# [
|
20
|
+
# {
|
21
|
+
# "feature1": 23.33,
|
22
|
+
# "target": 2.59
|
23
|
+
# },
|
24
|
+
# {
|
25
|
+
# "feature1": 15.82,
|
26
|
+
# "target": 1.75
|
27
|
+
# }
|
28
|
+
# ]
|
29
|
+
attr_accessor :predictions
|
30
|
+
|
31
|
+
# A list of warning message optionally returned from prediction run
|
32
|
+
# @return [Array]
|
33
|
+
attr_accessor :messages
|
34
|
+
end
|
35
|
+
end
|