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,63 +5,63 @@
|
|
|
5
5
|
module RecombeeApiClient
|
|
6
6
|
require_relative 'request'
|
|
7
7
|
require_relative '../errors'
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
##
|
|
10
|
-
#Recommends the top Segments from a [Segmentation](https://docs.recombee.com/segmentations) for a particular user, based on the user's past interactions.
|
|
10
|
+
# Recommends the top Segments from a [Segmentation](https://docs.recombee.com/segmentations) for a particular user, based on the user's past interactions.
|
|
11
11
|
#
|
|
12
|
-
#Based on the used Segmentation, this endpoint can be used for example for:
|
|
12
|
+
# Based on the used Segmentation, this endpoint can be used for example for:
|
|
13
13
|
#
|
|
14
14
|
# - Recommending the top categories for the user
|
|
15
15
|
# - Recommending the top genres for the user
|
|
16
16
|
# - Recommending the top brands for the user
|
|
17
17
|
# - Recommending the top artists for the user
|
|
18
18
|
#
|
|
19
|
-
#You need to set the used Segmentation the Admin UI in the [Scenario settings](https://docs.recombee.com/scenarios) prior to using this endpoint.
|
|
19
|
+
# You need to set the used Segmentation the Admin UI in the [Scenario settings](https://docs.recombee.com/scenarios) prior to using this endpoint.
|
|
20
20
|
#
|
|
21
|
-
#The returned segments are sorted by relevance (first segment being the most relevant).
|
|
21
|
+
# The returned segments are sorted by relevance (first segment being the most relevant).
|
|
22
22
|
#
|
|
23
|
-
#It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
|
|
23
|
+
# It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
|
|
24
24
|
#
|
|
25
25
|
class RecommendItemSegmentsToUser < ApiRequest
|
|
26
|
-
attr_reader :user_id, :count, :scenario, :cascade_create, :filter, :booster, :logic, :expert_settings,
|
|
27
|
-
|
|
28
|
-
attr_accessor :ensure_https
|
|
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
|
-
|
|
26
|
+
attr_reader :user_id, :count, :scenario, :cascade_create, :filter, :booster, :logic, :expert_settings,
|
|
27
|
+
:return_ab_group
|
|
28
|
+
attr_accessor :timeout, :ensure_https
|
|
29
|
+
|
|
30
|
+
##
|
|
31
|
+
# * *Required arguments*
|
|
32
|
+
# - +user_id+ -> ID of the user for whom personalized recommendations are to be generated.
|
|
33
|
+
# - +count+ -> Number of item segments to be recommended (N for the top-N recommendation).
|
|
34
|
+
#
|
|
35
|
+
#
|
|
36
|
+
# * *Optional arguments (given as hash optional)*
|
|
37
|
+
# - +scenario+ -> Scenario defines a particular application of recommendations. It can be, for example, "homepage", "cart", or "emailing".
|
|
38
|
+
#
|
|
39
|
+
# 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.
|
|
40
|
+
#
|
|
41
|
+
# 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.
|
|
42
|
+
#
|
|
43
|
+
# - +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.
|
|
44
|
+
#
|
|
45
|
+
# - +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql) expression which allows you to filter recommended segments based on the `segmentationId`.
|
|
46
|
+
#
|
|
47
|
+
# - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql) expression which allows you to boost recommendation rate of some segments based on the `segmentationId`.
|
|
48
|
+
#
|
|
49
|
+
# - +logic+ -> Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case.
|
|
50
|
+
# See [this section](https://docs.recombee.com/recommendation_logics) for a list of available logics and other details.
|
|
51
|
+
#
|
|
52
|
+
# The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
|
|
53
|
+
#
|
|
54
|
+
# Logic can also be set to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
|
|
55
|
+
#
|
|
56
|
+
# - +expertSettings+ -> Dictionary of custom options.
|
|
57
|
+
#
|
|
58
|
+
# - +returnAbGroup+ -> If there is a custom AB-testing running, return the name of the group to which the request belongs.
|
|
59
|
+
#
|
|
60
|
+
#
|
|
61
61
|
def initialize(user_id, count, optional = {})
|
|
62
62
|
@user_id = user_id
|
|
63
63
|
@count = count
|
|
64
|
-
optional =
|
|
64
|
+
optional = normalize_hash_to_camel_case(optional)
|
|
65
65
|
@scenario = optional['scenario']
|
|
66
66
|
@cascade_create = optional['cascadeCreate']
|
|
67
67
|
@filter = optional['filter']
|
|
@@ -73,18 +73,19 @@ module RecombeeApiClient
|
|
|
73
73
|
@timeout = 3000
|
|
74
74
|
@ensure_https = false
|
|
75
75
|
@optional.each do |par, _|
|
|
76
|
-
|
|
76
|
+
raise UnknownOptionalParameter.new(par) unless %w[scenario cascadeCreate filter booster logic
|
|
77
|
+
expertSettings returnAbGroup].include? par
|
|
77
78
|
end
|
|
78
79
|
end
|
|
79
|
-
|
|
80
|
+
|
|
80
81
|
# HTTP method
|
|
81
82
|
def method
|
|
82
83
|
:post
|
|
83
84
|
end
|
|
84
|
-
|
|
85
|
+
|
|
85
86
|
# Values of body parameters as a Hash
|
|
86
87
|
def body_parameters
|
|
87
|
-
p =
|
|
88
|
+
p = {}
|
|
88
89
|
p['count'] = @count
|
|
89
90
|
p['scenario'] = @optional['scenario'] if @optional.include? 'scenario'
|
|
90
91
|
p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
|
|
@@ -93,16 +94,16 @@ module RecombeeApiClient
|
|
|
93
94
|
p['logic'] = @optional['logic'] if @optional.include? 'logic'
|
|
94
95
|
p['expertSettings'] = @optional['expertSettings'] if @optional.include? 'expertSettings'
|
|
95
96
|
p['returnAbGroup'] = @optional['returnAbGroup'] if @optional.include? 'returnAbGroup'
|
|
97
|
+
|
|
96
98
|
p
|
|
97
99
|
end
|
|
98
|
-
|
|
100
|
+
|
|
99
101
|
# Values of query parameters as a Hash.
|
|
100
102
|
# name of parameter => value of the parameter
|
|
101
103
|
def query_parameters
|
|
102
|
-
|
|
103
|
-
params
|
|
104
|
+
{}
|
|
104
105
|
end
|
|
105
|
-
|
|
106
|
+
|
|
106
107
|
# Relative path to the endpoint
|
|
107
108
|
def path
|
|
108
109
|
"/{databaseId}/recomms/users/#{@user_id}/item-segments/"
|
|
@@ -5,148 +5,191 @@
|
|
|
5
5
|
module RecombeeApiClient
|
|
6
6
|
require_relative 'request'
|
|
7
7
|
require_relative '../errors'
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
##
|
|
10
|
-
#Recommends a set of items that are somehow related to one given item, *X*. A typical scenario is when the user *A* is viewing *X*. Then you may display items to the user that he might also be interested in. Recommend items to item request gives you Top-N such items, optionally taking the target user *A* into account.
|
|
10
|
+
# Recommends a set of items that are somehow related to one given item, *X*. A typical scenario is when the user *A* is viewing *X*. Then you may display items to the user that he might also be interested in. Recommend items to item request gives you Top-N such items, optionally taking the target user *A* into account.
|
|
11
11
|
#
|
|
12
|
-
#The returned items are sorted by relevance (the first item being the most relevant).
|
|
12
|
+
# The returned items are sorted by relevance (the first item being the most relevant).
|
|
13
13
|
#
|
|
14
|
-
#Besides the recommended items, also a unique `recommId` is returned in the response. It can be used to:
|
|
14
|
+
# Besides the recommended items, also a unique `recommId` is returned in the response. It can be used to:
|
|
15
15
|
#
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
# - Let Recombee know that this recommendation was successful (e.g., user clicked one of the recommended items). See [Reported metrics](https://docs.recombee.com/admin_ui#reported-metrics).
|
|
17
|
+
# - Get subsequent recommended items when the user scrolls down (*infinite scroll*) or goes to the next page. See [Recommend Next Items](https://docs.recombee.com/api#recommend-next-items).
|
|
18
18
|
#
|
|
19
|
-
#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.
|
|
19
|
+
# 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.
|
|
20
20
|
#
|
|
21
21
|
class RecommendItemsToItem < ApiRequest
|
|
22
|
-
attr_reader :item_id, :target_user_id, :count, :scenario, :cascade_create, :return_properties,
|
|
23
|
-
|
|
24
|
-
attr_accessor :ensure_https
|
|
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
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
22
|
+
attr_reader :item_id, :target_user_id, :count, :scenario, :cascade_create, :return_properties,
|
|
23
|
+
:included_properties, :filter, :booster, :logic, :reql_expressions, :user_impact, :diversity, :min_relevance, :rotation_rate, :rotation_time, :expert_settings, :return_ab_group
|
|
24
|
+
attr_accessor :timeout, :ensure_https
|
|
25
|
+
|
|
26
|
+
##
|
|
27
|
+
# * *Required arguments*
|
|
28
|
+
# - +item_id+ -> ID of the item for which the recommendations are to be generated.
|
|
29
|
+
# - +target_user_id+ -> ID of the user who will see the recommendations.
|
|
30
|
+
#
|
|
31
|
+
# Specifying the *targetUserId* is beneficial because:
|
|
32
|
+
#
|
|
33
|
+
# * It makes the recommendations personalized
|
|
34
|
+
# * Allows the calculation of Actions and Conversions
|
|
35
|
+
# in the graphical user interface,
|
|
36
|
+
# as Recombee can pair the user who got recommendations
|
|
37
|
+
# and who afterward viewed/purchased an item.
|
|
38
|
+
#
|
|
39
|
+
# If you insist on not specifying the user, pass `null`
|
|
40
|
+
# (`None`, `nil`, `NULL` etc., depending on the language) to *targetUserId*.
|
|
41
|
+
# Do not create some special dummy user for getting recommendations,
|
|
42
|
+
# as it could mislead the recommendation models,
|
|
43
|
+
# and result in wrong recommendations.
|
|
44
|
+
#
|
|
45
|
+
# For anonymous/unregistered users, it is possible to use, for example, their session ID.
|
|
46
|
+
#
|
|
47
|
+
# - +count+ -> Number of items to be recommended (N for the top-N recommendation).
|
|
48
|
+
#
|
|
49
|
+
# * *Optional arguments (given as hash optional)*
|
|
50
|
+
# - +scenario+ -> Scenario defines a particular application of recommendations. It can be, for example, "homepage", "cart", or "emailing".
|
|
51
|
+
#
|
|
52
|
+
# 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.
|
|
53
|
+
#
|
|
54
|
+
# 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.
|
|
55
|
+
#
|
|
56
|
+
# - +cascadeCreate+ -> If an item of the given *itemId* or user of the given *targetUserId* doesn't exist in the database, it creates the missing entity/entities and returns some (non-personalized) recommendations. This allows, for example, rotations in the following recommendations for the user of the given *targetUserId*, as the user will be already known to the system.
|
|
57
|
+
# - +returnProperties+ -> With `returnProperties=true`, property values of the recommended items are returned along with their IDs in a JSON dictionary. The acquired property values can be used to easily display the recommended items to the user.
|
|
58
|
+
#
|
|
59
|
+
# Example response:
|
|
60
|
+
# ```json
|
|
61
|
+
# {
|
|
62
|
+
# "recommId": "0c6189e7-dc1a-429a-b613-192696309361",
|
|
63
|
+
# "recomms":
|
|
64
|
+
# [
|
|
65
|
+
# {
|
|
66
|
+
# "id": "tv-178",
|
|
67
|
+
# "values": {
|
|
68
|
+
# "description": "4K TV with 3D feature",
|
|
69
|
+
# "categories": ["Electronics", "Televisions"],
|
|
70
|
+
# "price": 342,
|
|
71
|
+
# "url": "myshop.com/tv-178"
|
|
72
|
+
# }
|
|
73
|
+
# },
|
|
74
|
+
# {
|
|
75
|
+
# "id": "mixer-42",
|
|
76
|
+
# "values": {
|
|
77
|
+
# "description": "Stainless Steel Mixer",
|
|
78
|
+
# "categories": ["Home & Kitchen"],
|
|
79
|
+
# "price": 39,
|
|
80
|
+
# "url": "myshop.com/mixer-42"
|
|
81
|
+
# }
|
|
82
|
+
# }
|
|
83
|
+
# ],
|
|
84
|
+
# "numberNextRecommsCalls": 0
|
|
85
|
+
# }
|
|
86
|
+
# ```
|
|
87
|
+
#
|
|
88
|
+
# - +includedProperties+ -> Allows specifying which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list.
|
|
89
|
+
#
|
|
90
|
+
# Example response for `includedProperties=description,price`:
|
|
91
|
+
# ```json
|
|
92
|
+
# {
|
|
93
|
+
# "recommId": "6842c725-a79f-4537-a02c-f34d668a3f80",
|
|
94
|
+
# "recomms":
|
|
95
|
+
# [
|
|
96
|
+
# {
|
|
97
|
+
# "id": "tv-178",
|
|
98
|
+
# "values": {
|
|
99
|
+
# "description": "4K TV with 3D feature",
|
|
100
|
+
# "price": 342
|
|
101
|
+
# }
|
|
102
|
+
# },
|
|
103
|
+
# {
|
|
104
|
+
# "id": "mixer-42",
|
|
105
|
+
# "values": {
|
|
106
|
+
# "description": "Stainless Steel Mixer",
|
|
107
|
+
# "price": 39
|
|
108
|
+
# }
|
|
109
|
+
# }
|
|
110
|
+
# ],
|
|
111
|
+
# "numberNextRecommsCalls": 0
|
|
112
|
+
# }
|
|
113
|
+
# ```
|
|
114
|
+
#
|
|
115
|
+
# - +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql) expression, which allows you to filter recommended items based on the values of their attributes.
|
|
116
|
+
#
|
|
117
|
+
# Filters can also be assigned to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
|
|
118
|
+
#
|
|
119
|
+
# - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql) expression, which allows you to boost the recommendation rate of some items based on the values of their attributes.
|
|
120
|
+
#
|
|
121
|
+
# Boosters can also be assigned to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
|
|
122
|
+
#
|
|
123
|
+
# - +logic+ -> Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case.
|
|
124
|
+
# See [this section](https://docs.recombee.com/recommendation_logics) for a list of available logics and other details.
|
|
125
|
+
#
|
|
126
|
+
# The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
|
|
127
|
+
#
|
|
128
|
+
# Logic can also be set to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
|
|
129
|
+
#
|
|
130
|
+
# - +reqlExpressions+ -> A dictionary of [ReQL](https://docs.recombee.com/reql) expressions that will be executed for each recommended item.
|
|
131
|
+
# This can be used to compute additional properties of the recommended items that are not stored in the database.
|
|
132
|
+
#
|
|
133
|
+
# The keys are the names of the expressions, and the values are the actual ReQL expressions.
|
|
134
|
+
#
|
|
135
|
+
# Example request:
|
|
136
|
+
# ```json
|
|
137
|
+
# {
|
|
138
|
+
# "reqlExpressions": {
|
|
139
|
+
# "isInUsersCity": "context_user[\"city\"] in 'cities'",
|
|
140
|
+
# "distanceToUser": "earth_distance('location', context_user[\"location\"])",
|
|
141
|
+
# "isFromSameCompany": "'company' == context_item[\"company\"]"
|
|
142
|
+
# }
|
|
143
|
+
# }
|
|
144
|
+
# ```
|
|
145
|
+
#
|
|
146
|
+
# Example response:
|
|
147
|
+
# ```json
|
|
148
|
+
# {
|
|
149
|
+
# "recommId": "ce52ada4-e4d9-4885-943c-407db2dee837",
|
|
150
|
+
# "recomms":
|
|
151
|
+
# [
|
|
152
|
+
# {
|
|
153
|
+
# "id": "restaurant-178",
|
|
154
|
+
# "reqlEvaluations": {
|
|
155
|
+
# "isInUsersCity": true,
|
|
156
|
+
# "distanceToUser": 5200.2,
|
|
157
|
+
# "isFromSameCompany": false
|
|
158
|
+
# }
|
|
159
|
+
# },
|
|
160
|
+
# {
|
|
161
|
+
# "id": "bar-42",
|
|
162
|
+
# "reqlEvaluations": {
|
|
163
|
+
# "isInUsersCity": false,
|
|
164
|
+
# "distanceToUser": 2516.0,
|
|
165
|
+
# "isFromSameCompany": true
|
|
166
|
+
# }
|
|
167
|
+
# }
|
|
168
|
+
# ],
|
|
169
|
+
# "numberNextRecommsCalls": 0
|
|
170
|
+
# }
|
|
171
|
+
# ```
|
|
172
|
+
#
|
|
173
|
+
# - +userImpact+ -> **Expert option:** If *targetUserId* parameter is present, the recommendations are biased towards the given user. Using *userImpact*, you may control this bias. For an extreme case of `userImpact=0.0`, the interactions made by the user are not taken into account at all (with the exception of history-based blacklisting), for `userImpact=1.0`, you'll get a user-based recommendation. The default value is `0`.
|
|
174
|
+
#
|
|
175
|
+
# - +diversity+ -> **Expert option:** Real number from [0.0, 1.0], which determines how mutually dissimilar the recommended items should be. The default value is 0.0, i.e., no diversification. Value 1.0 means maximal diversification.
|
|
176
|
+
#
|
|
177
|
+
# - +minRelevance+ -> **Expert option:** If the *targetUserId* is provided: Specifies the threshold of how relevant must the recommended items be to the user. Possible values one of: "low", "medium", "high". The default value is "low", meaning that the system attempts to recommend a number of items equal to *count* at any cost. If there is not enough data (such as interactions or item properties), this may even lead to bestseller-based recommendations being appended to reach the full *count*. This behavior may be suppressed by using "medium" or "high" values. In such case, the system only recommends items of at least the requested relevance and may return less than *count* items when there is not enough data to fulfill it.
|
|
178
|
+
#
|
|
179
|
+
# - +rotationRate+ -> **Expert option:** If the *targetUserId* is provided: 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 an item 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 items.
|
|
180
|
+
#
|
|
181
|
+
# - +rotationTime+ -> **Expert option:** If the *targetUserId* is provided: Taking *rotationRate* into account, specifies how long it takes for an item to recover from the penalization. For example, `rotationTime=7200.0` means that items recommended less than 2 hours ago are penalized.
|
|
182
|
+
#
|
|
183
|
+
# - +expertSettings+ -> Dictionary of custom options.
|
|
184
|
+
#
|
|
185
|
+
# - +returnAbGroup+ -> If there is a custom AB-testing running, return the name of the group to which the request belongs.
|
|
186
|
+
#
|
|
187
|
+
#
|
|
145
188
|
def initialize(item_id, target_user_id, count, optional = {})
|
|
146
189
|
@item_id = item_id
|
|
147
190
|
@target_user_id = target_user_id
|
|
148
191
|
@count = count
|
|
149
|
-
optional =
|
|
192
|
+
optional = normalize_hash_to_camel_case(optional)
|
|
150
193
|
@scenario = optional['scenario']
|
|
151
194
|
@cascade_create = optional['cascadeCreate']
|
|
152
195
|
@return_properties = optional['returnProperties']
|
|
@@ -154,6 +197,7 @@ module RecombeeApiClient
|
|
|
154
197
|
@filter = optional['filter']
|
|
155
198
|
@booster = optional['booster']
|
|
156
199
|
@logic = optional['logic']
|
|
200
|
+
@reql_expressions = optional['reqlExpressions']
|
|
157
201
|
@user_impact = optional['userImpact']
|
|
158
202
|
@diversity = optional['diversity']
|
|
159
203
|
@min_relevance = optional['minRelevance']
|
|
@@ -165,18 +209,19 @@ module RecombeeApiClient
|
|
|
165
209
|
@timeout = 3000
|
|
166
210
|
@ensure_https = false
|
|
167
211
|
@optional.each do |par, _|
|
|
168
|
-
|
|
212
|
+
raise UnknownOptionalParameter.new(par) unless %w[scenario cascadeCreate returnProperties
|
|
213
|
+
includedProperties filter booster logic reqlExpressions userImpact diversity minRelevance rotationRate rotationTime expertSettings returnAbGroup].include? par
|
|
169
214
|
end
|
|
170
215
|
end
|
|
171
|
-
|
|
216
|
+
|
|
172
217
|
# HTTP method
|
|
173
218
|
def method
|
|
174
219
|
:post
|
|
175
220
|
end
|
|
176
|
-
|
|
221
|
+
|
|
177
222
|
# Values of body parameters as a Hash
|
|
178
223
|
def body_parameters
|
|
179
|
-
p =
|
|
224
|
+
p = {}
|
|
180
225
|
p['targetUserId'] = @target_user_id
|
|
181
226
|
p['count'] = @count
|
|
182
227
|
p['scenario'] = @optional['scenario'] if @optional.include? 'scenario'
|
|
@@ -186,6 +231,7 @@ module RecombeeApiClient
|
|
|
186
231
|
p['filter'] = @optional['filter'] if @optional.include? 'filter'
|
|
187
232
|
p['booster'] = @optional['booster'] if @optional.include? 'booster'
|
|
188
233
|
p['logic'] = @optional['logic'] if @optional.include? 'logic'
|
|
234
|
+
p['reqlExpressions'] = @optional['reqlExpressions'] if @optional.include? 'reqlExpressions'
|
|
189
235
|
p['userImpact'] = @optional['userImpact'] if @optional.include? 'userImpact'
|
|
190
236
|
p['diversity'] = @optional['diversity'] if @optional.include? 'diversity'
|
|
191
237
|
p['minRelevance'] = @optional['minRelevance'] if @optional.include? 'minRelevance'
|
|
@@ -193,16 +239,16 @@ module RecombeeApiClient
|
|
|
193
239
|
p['rotationTime'] = @optional['rotationTime'] if @optional.include? 'rotationTime'
|
|
194
240
|
p['expertSettings'] = @optional['expertSettings'] if @optional.include? 'expertSettings'
|
|
195
241
|
p['returnAbGroup'] = @optional['returnAbGroup'] if @optional.include? 'returnAbGroup'
|
|
242
|
+
|
|
196
243
|
p
|
|
197
244
|
end
|
|
198
|
-
|
|
245
|
+
|
|
199
246
|
# Values of query parameters as a Hash.
|
|
200
247
|
# name of parameter => value of the parameter
|
|
201
248
|
def query_parameters
|
|
202
|
-
|
|
203
|
-
params
|
|
249
|
+
{}
|
|
204
250
|
end
|
|
205
|
-
|
|
251
|
+
|
|
206
252
|
# Relative path to the endpoint
|
|
207
253
|
def path
|
|
208
254
|
"/{databaseId}/recomms/items/#{@item_id}/items/"
|