recombee_api_client 5.1.0 → 6.0.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/recombee_api_client/api/add_bookmark.rb +26 -26
- data/lib/recombee_api_client/api/add_cart_addition.rb +28 -28
- data/lib/recombee_api_client/api/add_detail_view.rb +32 -28
- data/lib/recombee_api_client/api/add_item.rb +15 -18
- data/lib/recombee_api_client/api/add_item_property.rb +34 -35
- data/lib/recombee_api_client/api/add_manual_reql_segment.rb +26 -27
- data/lib/recombee_api_client/api/add_purchase.rb +29 -29
- data/lib/recombee_api_client/api/add_rating.rb +27 -27
- data/lib/recombee_api_client/api/add_search_synonym.rb +29 -30
- data/lib/recombee_api_client/api/add_series.rb +20 -21
- data/lib/recombee_api_client/api/add_user.rb +14 -17
- data/lib/recombee_api_client/api/add_user_property.rb +30 -31
- data/lib/recombee_api_client/api/batch.rb +12 -16
- data/lib/recombee_api_client/api/composite_recommendation.rb +132 -0
- data/lib/recombee_api_client/api/create_auto_reql_segmentation.rb +29 -30
- data/lib/recombee_api_client/api/create_manual_reql_segmentation.rb +27 -28
- data/lib/recombee_api_client/api/create_property_based_segmentation.rb +30 -31
- data/lib/recombee_api_client/api/delete_all_search_synonyms.rb +15 -19
- data/lib/recombee_api_client/api/delete_bookmark.rb +21 -22
- data/lib/recombee_api_client/api/delete_cart_addition.rb +21 -22
- data/lib/recombee_api_client/api/delete_detail_view.rb +21 -22
- data/lib/recombee_api_client/api/delete_item.rb +16 -19
- data/lib/recombee_api_client/api/delete_item_property.rb +15 -18
- data/lib/recombee_api_client/api/delete_manual_reql_segment.rb +16 -19
- data/lib/recombee_api_client/api/delete_more_items.rb +18 -19
- data/lib/recombee_api_client/api/delete_purchase.rb +21 -22
- data/lib/recombee_api_client/api/delete_rating.rb +21 -22
- data/lib/recombee_api_client/api/delete_search_synonym.rb +15 -18
- data/lib/recombee_api_client/api/delete_segmentation.rb +15 -18
- data/lib/recombee_api_client/api/delete_series.rb +21 -22
- data/lib/recombee_api_client/api/delete_user.rb +15 -18
- data/lib/recombee_api_client/api/delete_user_property.rb +15 -18
- data/lib/recombee_api_client/api/delete_view_portion.rb +21 -22
- data/lib/recombee_api_client/api/get_item_property_info.rb +14 -17
- data/lib/recombee_api_client/api/get_item_values.rb +15 -18
- data/lib/recombee_api_client/api/get_segmentation.rb +15 -18
- data/lib/recombee_api_client/api/get_user_property_info.rb +15 -18
- data/lib/recombee_api_client/api/get_user_values.rb +15 -18
- data/lib/recombee_api_client/api/insert_to_series.rb +23 -24
- data/lib/recombee_api_client/api/list_item_bookmarks.rb +16 -19
- data/lib/recombee_api_client/api/list_item_cart_additions.rb +16 -19
- data/lib/recombee_api_client/api/list_item_detail_views.rb +16 -19
- data/lib/recombee_api_client/api/list_item_properties.rb +15 -19
- data/lib/recombee_api_client/api/list_item_purchases.rb +16 -19
- data/lib/recombee_api_client/api/list_item_ratings.rb +16 -19
- data/lib/recombee_api_client/api/list_item_view_portions.rb +16 -19
- data/lib/recombee_api_client/api/list_items.rb +62 -62
- data/lib/recombee_api_client/api/list_scenarios.rb +15 -19
- data/lib/recombee_api_client/api/list_search_synonyms.rb +20 -21
- data/lib/recombee_api_client/api/list_segmentations.rb +16 -17
- data/lib/recombee_api_client/api/list_series.rb +15 -19
- data/lib/recombee_api_client/api/list_series_items.rb +15 -18
- data/lib/recombee_api_client/api/list_user_bookmarks.rb +15 -18
- data/lib/recombee_api_client/api/list_user_cart_additions.rb +15 -18
- data/lib/recombee_api_client/api/list_user_detail_views.rb +15 -18
- data/lib/recombee_api_client/api/list_user_properties.rb +15 -19
- data/lib/recombee_api_client/api/list_user_purchases.rb +15 -18
- data/lib/recombee_api_client/api/list_user_ratings.rb +15 -18
- data/lib/recombee_api_client/api/list_user_view_portions.rb +15 -18
- data/lib/recombee_api_client/api/list_users.rb +56 -56
- data/lib/recombee_api_client/api/merge_users.rb +24 -25
- data/lib/recombee_api_client/api/recommend_item_segments_to_item.rb +69 -68
- data/lib/recombee_api_client/api/recommend_item_segments_to_item_segment.rb +70 -69
- data/lib/recombee_api_client/api/recommend_item_segments_to_user.rb +51 -50
- data/lib/recombee_api_client/api/recommend_items_to_item.rb +185 -139
- data/lib/recombee_api_client/api/recommend_items_to_item_segment.rb +181 -138
- data/lib/recombee_api_client/api/recommend_items_to_user.rb +165 -122
- data/lib/recombee_api_client/api/recommend_next_items.rb +24 -25
- data/lib/recombee_api_client/api/recommend_users_to_item.rb +151 -105
- data/lib/recombee_api_client/api/recommend_users_to_user.rb +154 -111
- data/lib/recombee_api_client/api/remove_from_series.rb +17 -18
- data/lib/recombee_api_client/api/request.rb +1 -1
- data/lib/recombee_api_client/api/reset_database.rb +15 -19
- data/lib/recombee_api_client/api/search_item_segments.rb +52 -51
- data/lib/recombee_api_client/api/search_items.rb +157 -114
- data/lib/recombee_api_client/api/set_item_values.rb +28 -29
- data/lib/recombee_api_client/api/set_user_values.rb +21 -22
- data/lib/recombee_api_client/api/set_values.rb +28 -28
- data/lib/recombee_api_client/api/set_view_portion.rb +37 -30
- data/lib/recombee_api_client/api/update_auto_reql_segmentation.rb +26 -27
- data/lib/recombee_api_client/api/update_manual_reql_segment.rb +25 -26
- data/lib/recombee_api_client/api/update_manual_reql_segmentation.rb +24 -25
- data/lib/recombee_api_client/api/update_more_items.rb +19 -20
- data/lib/recombee_api_client/api/update_property_based_segmentation.rb +26 -27
- data/lib/recombee_api_client/errors.rb +2 -5
- data/lib/recombee_api_client/inputs/composite_recommendation_stage_parameters.rb +240 -0
- data/lib/recombee_api_client/inputs/input.rb +9 -0
- data/lib/recombee_api_client/inputs/logic.rb +45 -0
- data/lib/recombee_api_client/utils/hash_normalizer.rb +21 -0
- data/lib/recombee_api_client/version.rb +1 -1
- data/lib/recombee_api_client.rb +40 -35
- data/recombee_api_client.gemspec +2 -3
- metadata +14 -10
- data/lib/recombee_api_client/api/hash_normalizer.rb +0 -21
|
@@ -5,110 +5,153 @@
|
|
|
5
5
|
module RecombeeApiClient
|
|
6
6
|
require_relative 'request'
|
|
7
7
|
require_relative '../errors'
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
##
|
|
10
|
-
#Recommends users that are likely to be interested in the given item.
|
|
10
|
+
# Recommends users that are likely to be interested in the given item.
|
|
11
11
|
#
|
|
12
|
-
#It is also possible to use POST HTTP method (for example in the case of a very long ReQL filter) - query parameters then become body parameters.
|
|
12
|
+
# It is also possible to use POST HTTP method (for example in the case of a very long ReQL filter) - query parameters then become body parameters.
|
|
13
13
|
#
|
|
14
|
-
#The returned users are sorted by predicted interest in the item (the first user being the most interested).
|
|
14
|
+
# The returned users are sorted by predicted interest in the item (the first user being the most interested).
|
|
15
15
|
#
|
|
16
16
|
class RecommendUsersToItem < ApiRequest
|
|
17
|
-
attr_reader :item_id, :count, :scenario, :cascade_create, :return_properties, :included_properties, :filter,
|
|
18
|
-
|
|
19
|
-
attr_accessor :ensure_https
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
17
|
+
attr_reader :item_id, :count, :scenario, :cascade_create, :return_properties, :included_properties, :filter,
|
|
18
|
+
:booster, :logic, :reql_expressions, :diversity, :expert_settings, :return_ab_group
|
|
19
|
+
attr_accessor :timeout, :ensure_https
|
|
20
|
+
|
|
21
|
+
##
|
|
22
|
+
# * *Required arguments*
|
|
23
|
+
# - +item_id+ -> ID of the item for which the recommendations are to be generated.
|
|
24
|
+
# - +count+ -> Number of users to be recommended (N for the top-N recommendation).
|
|
25
|
+
#
|
|
26
|
+
# * *Optional arguments (given as hash optional)*
|
|
27
|
+
# - +scenario+ -> Scenario defines a particular application of recommendations. It can be, for example, "homepage", "cart", or "emailing".
|
|
28
|
+
#
|
|
29
|
+
# You can set various settings to the [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com). You can also see the performance of each scenario in the Admin UI separately, so you can check how well each application performs.
|
|
30
|
+
#
|
|
31
|
+
# The AI that optimizes models to get the best results may optimize different scenarios separately or even use different models in each of the scenarios.
|
|
32
|
+
#
|
|
33
|
+
# - +cascadeCreate+ -> If an item of the given *itemId* doesn't exist in the database, it creates the missing item.
|
|
34
|
+
# - +returnProperties+ -> With `returnProperties=true`, property values of the recommended users are returned along with their IDs in a JSON dictionary. The acquired property values can be used to easily display the recommended users.
|
|
35
|
+
#
|
|
36
|
+
# Example response:
|
|
37
|
+
# ```json
|
|
38
|
+
# {
|
|
39
|
+
# "recommId": "039b71dc-b9cc-4645-a84f-62b841eecfce",
|
|
40
|
+
# "recomms":
|
|
41
|
+
# [
|
|
42
|
+
# {
|
|
43
|
+
# "id": "user-17",
|
|
44
|
+
# "values": {
|
|
45
|
+
# "country": "US",
|
|
46
|
+
# "sex": "F"
|
|
47
|
+
# }
|
|
48
|
+
# },
|
|
49
|
+
# {
|
|
50
|
+
# "id": "user-2",
|
|
51
|
+
# "values": {
|
|
52
|
+
# "country": "CAN",
|
|
53
|
+
# "sex": "M"
|
|
54
|
+
# }
|
|
55
|
+
# }
|
|
56
|
+
# ],
|
|
57
|
+
# "numberNextRecommsCalls": 0
|
|
58
|
+
# }
|
|
59
|
+
# ```
|
|
60
|
+
#
|
|
61
|
+
# - +includedProperties+ -> Allows specifying which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list.
|
|
62
|
+
#
|
|
63
|
+
# Example response for `includedProperties=country`:
|
|
64
|
+
# ```json
|
|
65
|
+
# {
|
|
66
|
+
# "recommId": "b2b355dd-972a-4728-9c6b-2dc229db0678",
|
|
67
|
+
# "recomms":
|
|
68
|
+
# [
|
|
69
|
+
# {
|
|
70
|
+
# "id": "user-17",
|
|
71
|
+
# "values": {
|
|
72
|
+
# "country": "US"
|
|
73
|
+
# }
|
|
74
|
+
# },
|
|
75
|
+
# {
|
|
76
|
+
# "id": "user-2",
|
|
77
|
+
# "values": {
|
|
78
|
+
# "country": "CAN"
|
|
79
|
+
# }
|
|
80
|
+
# }
|
|
81
|
+
# ],
|
|
82
|
+
# "numberNextRecommsCalls": 0
|
|
83
|
+
# }
|
|
84
|
+
# ```
|
|
85
|
+
#
|
|
86
|
+
# - +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql) expression, which allows you to filter recommended users based on the values of their attributes.
|
|
87
|
+
#
|
|
88
|
+
# Filters can also be assigned to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
|
|
89
|
+
#
|
|
90
|
+
# - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql) expression, which allows you to boost the recommendation rate of some users based on the values of their attributes.
|
|
91
|
+
#
|
|
92
|
+
# Boosters can also be assigned to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
|
|
93
|
+
#
|
|
94
|
+
# - +logic+ -> Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case.
|
|
95
|
+
# See [this section](https://docs.recombee.com/recommendation_logics) for a list of available logics and other details.
|
|
96
|
+
#
|
|
97
|
+
# The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
|
|
98
|
+
#
|
|
99
|
+
# Logic can also be set to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
|
|
100
|
+
#
|
|
101
|
+
# - +reqlExpressions+ -> A dictionary of [ReQL](https://docs.recombee.com/reql) expressions that will be executed for each recommended user.
|
|
102
|
+
# This can be used to compute additional properties of the recommended users that are not stored in the database.
|
|
103
|
+
#
|
|
104
|
+
# The keys are the names of the expressions, and the values are the actual ReQL expressions.
|
|
105
|
+
#
|
|
106
|
+
# Example request:
|
|
107
|
+
# ```json
|
|
108
|
+
# {
|
|
109
|
+
# "reqlExpressions": {
|
|
110
|
+
# "isInUsersCity": "context_user[\"city\"] in 'cities'",
|
|
111
|
+
# "distanceToUser": "earth_distance('location', context_user[\"location\"])",
|
|
112
|
+
# "isFromSameCompany": "'company' == context_item[\"company\"]"
|
|
113
|
+
# }
|
|
114
|
+
# }
|
|
115
|
+
# ```
|
|
116
|
+
#
|
|
117
|
+
# Example response:
|
|
118
|
+
# ```json
|
|
119
|
+
# {
|
|
120
|
+
# "recommId": "ce52ada4-e4d9-4885-943c-407db2dee837",
|
|
121
|
+
# "recomms":
|
|
122
|
+
# [
|
|
123
|
+
# {
|
|
124
|
+
# "id": "restaurant-178",
|
|
125
|
+
# "reqlEvaluations": {
|
|
126
|
+
# "isInUsersCity": true,
|
|
127
|
+
# "distanceToUser": 5200.2,
|
|
128
|
+
# "isFromSameCompany": false
|
|
129
|
+
# }
|
|
130
|
+
# },
|
|
131
|
+
# {
|
|
132
|
+
# "id": "bar-42",
|
|
133
|
+
# "reqlEvaluations": {
|
|
134
|
+
# "isInUsersCity": false,
|
|
135
|
+
# "distanceToUser": 2516.0,
|
|
136
|
+
# "isFromSameCompany": true
|
|
137
|
+
# }
|
|
138
|
+
# }
|
|
139
|
+
# ],
|
|
140
|
+
# "numberNextRecommsCalls": 0
|
|
141
|
+
# }
|
|
142
|
+
# ```
|
|
143
|
+
#
|
|
144
|
+
# - +diversity+ -> **Expert option:** Real number from [0.0, 1.0], which determines how mutually dissimilar the recommended users should be. The default value is 0.0, i.e., no diversification. Value 1.0 means maximal diversification.
|
|
145
|
+
#
|
|
146
|
+
# - +expertSettings+ -> Dictionary of custom options.
|
|
147
|
+
#
|
|
148
|
+
# - +returnAbGroup+ -> If there is a custom AB-testing running, return the name of the group to which the request belongs.
|
|
149
|
+
#
|
|
150
|
+
#
|
|
108
151
|
def initialize(item_id, count, optional = {})
|
|
109
152
|
@item_id = item_id
|
|
110
153
|
@count = count
|
|
111
|
-
optional =
|
|
154
|
+
optional = normalize_hash_to_camel_case(optional)
|
|
112
155
|
@scenario = optional['scenario']
|
|
113
156
|
@cascade_create = optional['cascadeCreate']
|
|
114
157
|
@return_properties = optional['returnProperties']
|
|
@@ -116,25 +159,27 @@ module RecombeeApiClient
|
|
|
116
159
|
@filter = optional['filter']
|
|
117
160
|
@booster = optional['booster']
|
|
118
161
|
@logic = optional['logic']
|
|
162
|
+
@reql_expressions = optional['reqlExpressions']
|
|
119
163
|
@diversity = optional['diversity']
|
|
120
164
|
@expert_settings = optional['expertSettings']
|
|
121
165
|
@return_ab_group = optional['returnAbGroup']
|
|
122
166
|
@optional = optional
|
|
123
|
-
@timeout =
|
|
167
|
+
@timeout = 50_000
|
|
124
168
|
@ensure_https = false
|
|
125
169
|
@optional.each do |par, _|
|
|
126
|
-
|
|
170
|
+
raise UnknownOptionalParameter.new(par) unless %w[scenario cascadeCreate returnProperties
|
|
171
|
+
includedProperties filter booster logic reqlExpressions diversity expertSettings returnAbGroup].include? par
|
|
127
172
|
end
|
|
128
173
|
end
|
|
129
|
-
|
|
174
|
+
|
|
130
175
|
# HTTP method
|
|
131
176
|
def method
|
|
132
177
|
:post
|
|
133
178
|
end
|
|
134
|
-
|
|
179
|
+
|
|
135
180
|
# Values of body parameters as a Hash
|
|
136
181
|
def body_parameters
|
|
137
|
-
p =
|
|
182
|
+
p = {}
|
|
138
183
|
p['count'] = @count
|
|
139
184
|
p['scenario'] = @optional['scenario'] if @optional.include? 'scenario'
|
|
140
185
|
p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
|
|
@@ -143,19 +188,20 @@ module RecombeeApiClient
|
|
|
143
188
|
p['filter'] = @optional['filter'] if @optional.include? 'filter'
|
|
144
189
|
p['booster'] = @optional['booster'] if @optional.include? 'booster'
|
|
145
190
|
p['logic'] = @optional['logic'] if @optional.include? 'logic'
|
|
191
|
+
p['reqlExpressions'] = @optional['reqlExpressions'] if @optional.include? 'reqlExpressions'
|
|
146
192
|
p['diversity'] = @optional['diversity'] if @optional.include? 'diversity'
|
|
147
193
|
p['expertSettings'] = @optional['expertSettings'] if @optional.include? 'expertSettings'
|
|
148
194
|
p['returnAbGroup'] = @optional['returnAbGroup'] if @optional.include? 'returnAbGroup'
|
|
195
|
+
|
|
149
196
|
p
|
|
150
197
|
end
|
|
151
|
-
|
|
198
|
+
|
|
152
199
|
# Values of query parameters as a Hash.
|
|
153
200
|
# name of parameter => value of the parameter
|
|
154
201
|
def query_parameters
|
|
155
|
-
|
|
156
|
-
params
|
|
202
|
+
{}
|
|
157
203
|
end
|
|
158
|
-
|
|
204
|
+
|
|
159
205
|
# Relative path to the endpoint
|
|
160
206
|
def path
|
|
161
207
|
"/{databaseId}/recomms/items/#{@item_id}/users/"
|
|
@@ -5,116 +5,156 @@
|
|
|
5
5
|
module RecombeeApiClient
|
|
6
6
|
require_relative 'request'
|
|
7
7
|
require_relative '../errors'
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
##
|
|
10
|
-
#Gets users similar to the given user, based on the user's past interactions (purchases, ratings, etc.) and values of properties.
|
|
10
|
+
# Gets users similar to the given user, based on the user's past interactions (purchases, ratings, etc.) and values of properties.
|
|
11
11
|
#
|
|
12
|
-
#It is also possible to use POST HTTP method (for example in the case of a very long ReQL filter) - query parameters then become body parameters.
|
|
12
|
+
# It is also possible to use POST HTTP method (for example in the case of a very long ReQL filter) - query parameters then become body parameters.
|
|
13
13
|
#
|
|
14
|
-
#The returned users are sorted by similarity (the first user being the most similar).
|
|
14
|
+
# The returned users are sorted by similarity (the first user being the most similar).
|
|
15
15
|
#
|
|
16
16
|
class RecommendUsersToUser < ApiRequest
|
|
17
|
-
attr_reader :user_id, :count, :scenario, :cascade_create, :return_properties, :included_properties, :filter,
|
|
18
|
-
|
|
19
|
-
attr_accessor :ensure_https
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
17
|
+
attr_reader :user_id, :count, :scenario, :cascade_create, :return_properties, :included_properties, :filter,
|
|
18
|
+
:booster, :logic, :reql_expressions, :diversity, :min_relevance, :rotation_rate, :rotation_time, :expert_settings, :return_ab_group
|
|
19
|
+
attr_accessor :timeout, :ensure_https
|
|
20
|
+
|
|
21
|
+
##
|
|
22
|
+
# * *Required arguments*
|
|
23
|
+
# - +user_id+ -> User to whom we find similar users
|
|
24
|
+
# - +count+ -> Number of users to be recommended (N for the top-N recommendation).
|
|
25
|
+
#
|
|
26
|
+
# * *Optional arguments (given as hash optional)*
|
|
27
|
+
# - +scenario+ -> Scenario defines a particular application of recommendations. It can be, for example, "homepage", "cart", or "emailing".
|
|
28
|
+
#
|
|
29
|
+
# You can set various settings to the [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com). You can also see the performance of each scenario in the Admin UI separately, so you can check how well each application performs.
|
|
30
|
+
#
|
|
31
|
+
# The AI that optimizes models to get the best results may optimize different scenarios separately or even use different models in each of the scenarios.
|
|
32
|
+
#
|
|
33
|
+
# - +cascadeCreate+ -> If the user does not exist in the database, returns a list of non-personalized recommendations and creates the user in the database. This allows, for example, rotations in the following recommendations for that user, as the user will be already known to the system.
|
|
34
|
+
# - +returnProperties+ -> With `returnProperties=true`, property values of the recommended users are returned along with their IDs in a JSON dictionary. The acquired property values can be used to easily display the recommended users.
|
|
35
|
+
#
|
|
36
|
+
# Example response:
|
|
37
|
+
# ```json
|
|
38
|
+
# {
|
|
39
|
+
# "recommId": "9cb9c55d-50ba-4478-84fd-ab456136156e",
|
|
40
|
+
# "recomms":
|
|
41
|
+
# [
|
|
42
|
+
# {
|
|
43
|
+
# "id": "user-17",
|
|
44
|
+
# "values": {
|
|
45
|
+
# "country": "US",
|
|
46
|
+
# "sex": "F"
|
|
47
|
+
# }
|
|
48
|
+
# },
|
|
49
|
+
# {
|
|
50
|
+
# "id": "user-2",
|
|
51
|
+
# "values": {
|
|
52
|
+
# "country": "CAN",
|
|
53
|
+
# "sex": "M"
|
|
54
|
+
# }
|
|
55
|
+
# }
|
|
56
|
+
# ],
|
|
57
|
+
# "numberNextRecommsCalls": 0
|
|
58
|
+
# }
|
|
59
|
+
# ```
|
|
60
|
+
#
|
|
61
|
+
# - +includedProperties+ -> Allows specifying which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list.
|
|
62
|
+
#
|
|
63
|
+
# Example response for `includedProperties=country`:
|
|
64
|
+
# ```json
|
|
65
|
+
# {
|
|
66
|
+
# "recommId": "b326d82d-5d57-4b45-b362-c9d6f0895855",
|
|
67
|
+
# "recomms":
|
|
68
|
+
# [
|
|
69
|
+
# {
|
|
70
|
+
# "id": "user-17",
|
|
71
|
+
# "values": {
|
|
72
|
+
# "country": "US"
|
|
73
|
+
# }
|
|
74
|
+
# },
|
|
75
|
+
# {
|
|
76
|
+
# "id": "user-2",
|
|
77
|
+
# "values": {
|
|
78
|
+
# "country": "CAN"
|
|
79
|
+
# }
|
|
80
|
+
# }
|
|
81
|
+
# ],
|
|
82
|
+
# "numberNextRecommsCalls": 0
|
|
83
|
+
# }
|
|
84
|
+
# ```
|
|
85
|
+
#
|
|
86
|
+
# - +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql) expression, which allows you to filter recommended users based on the values of their attributes.
|
|
87
|
+
#
|
|
88
|
+
# Filters can also be assigned to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
|
|
89
|
+
#
|
|
90
|
+
# - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql) expression, which allows you to boost the recommendation rate of some users based on the values of their attributes.
|
|
91
|
+
#
|
|
92
|
+
# Boosters can also be assigned to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
|
|
93
|
+
#
|
|
94
|
+
# - +logic+ -> Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case.
|
|
95
|
+
# See [this section](https://docs.recombee.com/recommendation_logics) for a list of available logics and other details.
|
|
96
|
+
#
|
|
97
|
+
# The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
|
|
98
|
+
#
|
|
99
|
+
# Logic can also be set to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
|
|
100
|
+
#
|
|
101
|
+
# - +reqlExpressions+ -> A dictionary of [ReQL](https://docs.recombee.com/reql) expressions that will be executed for each recommended user.
|
|
102
|
+
# This can be used to compute additional properties of the recommended users that are not stored in the database.
|
|
103
|
+
#
|
|
104
|
+
# The keys are the names of the expressions, and the values are the actual ReQL expressions.
|
|
105
|
+
#
|
|
106
|
+
# Example request:
|
|
107
|
+
# ```json
|
|
108
|
+
# {
|
|
109
|
+
# "reqlExpressions": {
|
|
110
|
+
# "isInUsersCity": "context_user[\"city\"] in 'cities'",
|
|
111
|
+
# "distanceToUser": "earth_distance('location', context_user[\"location\"])"
|
|
112
|
+
# }
|
|
113
|
+
# }
|
|
114
|
+
# ```
|
|
115
|
+
#
|
|
116
|
+
# Example response:
|
|
117
|
+
# ```json
|
|
118
|
+
# {
|
|
119
|
+
# "recommId": "ce52ada4-e4d9-4885-943c-407db2dee837",
|
|
120
|
+
# "recomms":
|
|
121
|
+
# [
|
|
122
|
+
# {
|
|
123
|
+
# "id": "restaurant-178",
|
|
124
|
+
# "reqlEvaluations": {
|
|
125
|
+
# "isInUsersCity": true,
|
|
126
|
+
# "distanceToUser": 5200.2
|
|
127
|
+
# }
|
|
128
|
+
# },
|
|
129
|
+
# {
|
|
130
|
+
# "id": "bar-42",
|
|
131
|
+
# "reqlEvaluations": {
|
|
132
|
+
# "isInUsersCity": false,
|
|
133
|
+
# "distanceToUser": 2516.0
|
|
134
|
+
# }
|
|
135
|
+
# }
|
|
136
|
+
# ],
|
|
137
|
+
# "numberNextRecommsCalls": 0
|
|
138
|
+
# }
|
|
139
|
+
# ```
|
|
140
|
+
#
|
|
141
|
+
# - +diversity+ -> **Expert option:** Real number from [0.0, 1.0], which determines how mutually dissimilar the recommended users should be. The default value is 0.0, i.e., no diversification. Value 1.0 means maximal diversification.
|
|
142
|
+
#
|
|
143
|
+
# - +minRelevance+ -> **Expert option:** Specifies the threshold of how relevant must the recommended users be. Possible values one of: "low", "medium", "high".
|
|
144
|
+
#
|
|
145
|
+
# - +rotationRate+ -> **Expert option:** If your users browse the system in real-time, it may easily happen that you wish to offer them recommendations multiple times. Here comes the question: how much should the recommendations change? Should they remain the same, or should they rotate? Recombee API allows you to control this per request in a backward fashion. You may penalize a user for being recommended in the near past. For the specific user, `rotationRate=1` means maximal rotation, `rotationRate=0` means absolutely no rotation. You may also use, for example, `rotationRate=0.2` for only slight rotation of recommended users.
|
|
146
|
+
#
|
|
147
|
+
# - +rotationTime+ -> **Expert option:** Taking *rotationRate* into account, specifies how long it takes for a user to recover from the penalization. For example, `rotationTime=7200.0` means that users recommended less than 2 hours ago are penalized.
|
|
148
|
+
#
|
|
149
|
+
# - +expertSettings+ -> Dictionary of custom options.
|
|
150
|
+
#
|
|
151
|
+
# - +returnAbGroup+ -> If there is a custom AB-testing running, return the name of the group to which the request belongs.
|
|
152
|
+
#
|
|
153
|
+
#
|
|
114
154
|
def initialize(user_id, count, optional = {})
|
|
115
155
|
@user_id = user_id
|
|
116
156
|
@count = count
|
|
117
|
-
optional =
|
|
157
|
+
optional = normalize_hash_to_camel_case(optional)
|
|
118
158
|
@scenario = optional['scenario']
|
|
119
159
|
@cascade_create = optional['cascadeCreate']
|
|
120
160
|
@return_properties = optional['returnProperties']
|
|
@@ -122,6 +162,7 @@ module RecombeeApiClient
|
|
|
122
162
|
@filter = optional['filter']
|
|
123
163
|
@booster = optional['booster']
|
|
124
164
|
@logic = optional['logic']
|
|
165
|
+
@reql_expressions = optional['reqlExpressions']
|
|
125
166
|
@diversity = optional['diversity']
|
|
126
167
|
@min_relevance = optional['minRelevance']
|
|
127
168
|
@rotation_rate = optional['rotationRate']
|
|
@@ -129,21 +170,22 @@ module RecombeeApiClient
|
|
|
129
170
|
@expert_settings = optional['expertSettings']
|
|
130
171
|
@return_ab_group = optional['returnAbGroup']
|
|
131
172
|
@optional = optional
|
|
132
|
-
@timeout =
|
|
173
|
+
@timeout = 50_000
|
|
133
174
|
@ensure_https = false
|
|
134
175
|
@optional.each do |par, _|
|
|
135
|
-
|
|
176
|
+
raise UnknownOptionalParameter.new(par) unless %w[scenario cascadeCreate returnProperties
|
|
177
|
+
includedProperties filter booster logic reqlExpressions diversity minRelevance rotationRate rotationTime expertSettings returnAbGroup].include? par
|
|
136
178
|
end
|
|
137
179
|
end
|
|
138
|
-
|
|
180
|
+
|
|
139
181
|
# HTTP method
|
|
140
182
|
def method
|
|
141
183
|
:post
|
|
142
184
|
end
|
|
143
|
-
|
|
185
|
+
|
|
144
186
|
# Values of body parameters as a Hash
|
|
145
187
|
def body_parameters
|
|
146
|
-
p =
|
|
188
|
+
p = {}
|
|
147
189
|
p['count'] = @count
|
|
148
190
|
p['scenario'] = @optional['scenario'] if @optional.include? 'scenario'
|
|
149
191
|
p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
|
|
@@ -152,22 +194,23 @@ module RecombeeApiClient
|
|
|
152
194
|
p['filter'] = @optional['filter'] if @optional.include? 'filter'
|
|
153
195
|
p['booster'] = @optional['booster'] if @optional.include? 'booster'
|
|
154
196
|
p['logic'] = @optional['logic'] if @optional.include? 'logic'
|
|
197
|
+
p['reqlExpressions'] = @optional['reqlExpressions'] if @optional.include? 'reqlExpressions'
|
|
155
198
|
p['diversity'] = @optional['diversity'] if @optional.include? 'diversity'
|
|
156
199
|
p['minRelevance'] = @optional['minRelevance'] if @optional.include? 'minRelevance'
|
|
157
200
|
p['rotationRate'] = @optional['rotationRate'] if @optional.include? 'rotationRate'
|
|
158
201
|
p['rotationTime'] = @optional['rotationTime'] if @optional.include? 'rotationTime'
|
|
159
202
|
p['expertSettings'] = @optional['expertSettings'] if @optional.include? 'expertSettings'
|
|
160
203
|
p['returnAbGroup'] = @optional['returnAbGroup'] if @optional.include? 'returnAbGroup'
|
|
204
|
+
|
|
161
205
|
p
|
|
162
206
|
end
|
|
163
|
-
|
|
207
|
+
|
|
164
208
|
# Values of query parameters as a Hash.
|
|
165
209
|
# name of parameter => value of the parameter
|
|
166
210
|
def query_parameters
|
|
167
|
-
|
|
168
|
-
params
|
|
211
|
+
{}
|
|
169
212
|
end
|
|
170
|
-
|
|
213
|
+
|
|
171
214
|
# Relative path to the endpoint
|
|
172
215
|
def path
|
|
173
216
|
"/{databaseId}/recomms/users/#{@user_id}/users/"
|