recombee_api_client 2.1.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,23 +9,37 @@ module RecombeeApiClient
9
9
  ##
10
10
  #Based on user's past interactions (purchases, ratings, etc.) with the items, recommends top-N items that are most likely to be of high value for a given user.
11
11
  #
12
+ #The most typical use cases are recommendations at homepage, in some "Picked just for you" section or in email.
13
+ #
14
+ #The returned items are sorted by relevance (first item being the most relevant).
15
+ #
16
+ #Besides the recommended items, also a unique `recommId` is returned in the response. It can be used to:
17
+ #
18
+ #- 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.html#reported-metrics).
19
+ #- 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.html#recommend-next-items).
20
+ #
12
21
  #It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
13
22
  #
14
23
  class RecommendItemsToUser < ApiRequest
15
- attr_reader :user_id, :count, :filter, :booster, :cascade_create, :scenario, :return_properties, :included_properties, :diversity, :min_relevance, :rotation_rate, :rotation_time, :expert_settings
24
+ attr_reader :user_id, :count, :scenario, :cascade_create, :return_properties, :included_properties, :filter, :booster, :logic, :diversity, :min_relevance, :rotation_rate, :rotation_time, :expert_settings, :return_ab_group
16
25
  attr_accessor :timeout
17
26
  attr_accessor :ensure_https
18
27
 
19
28
  ##
20
29
  # * *Required arguments*
21
- # - +user_id+ -> ID of the user for which personalized recommendations are to be generated.
30
+ # - +user_id+ -> ID of the user for whom personalized recommendations are to be generated.
22
31
  # - +count+ -> Number of items to be recommended (N for the top-N recommendation).
23
32
  #
33
+ #
24
34
  # * *Optional arguments (given as hash optional)*
25
- # - +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to filter recommended items based on the values of their attributes.
26
- # - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to boost recommendation rate of some items based on the values of their attributes.
35
+ # - +scenario+ -> Scenario defines a particular application of recommendations. It can be for example "homepage", "cart" or "emailing".
36
+ #
37
+ #You can set various settings to the [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com). You can also see performance of each scenario in the Admin UI separately, so you can check how well each application performs.
38
+ #
39
+ #The AI which optimizes models in order to get the best results may optimize different scenarios separately, or even use different models in each of the scenarios.
40
+ #
27
41
  # - +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.
28
- # - +scenario+ -> Scenario defines a particular application of recommendations. It can be for example "homepage", "cart" or "emailing". You can see each scenario in the UI separately, so you can check how well each application performs. The AI which optimizes models in order to get the best results may optimize different scenarios separately, or even use different models in each of the scenarios.
42
+ #
29
43
  # - +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 for easy displaying of the recommended items to the user.
30
44
  #
31
45
  #Example response:
@@ -52,7 +66,8 @@ module RecombeeApiClient
52
66
  # "url": "myshop.com/mixer-42"
53
67
  # }
54
68
  # }
55
- # ]
69
+ # ],
70
+ # "numberNextRecommsCalls": 0
56
71
  # }
57
72
  #```
58
73
  #
@@ -78,13 +93,29 @@ module RecombeeApiClient
78
93
  # "price": 39
79
94
  # }
80
95
  # }
81
- # ]
96
+ # ],
97
+ # "numberNextRecommsCalls": 0
82
98
  # }
83
99
  #```
84
100
  #
101
+ # - +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to filter recommended items based on the values of their attributes.
102
+ #
103
+ #Filters can be also assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
104
+ #
105
+ # - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to boost recommendation rate of some items based on the values of their attributes.
106
+ #
107
+ #Boosters can be also assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
108
+ #
109
+ # - +logic+ -> Logic specifies particular behavior of the recommendation models. You can pick tailored logic for your domain and use case.
110
+ #See [this section](https://docs.recombee.com/recommendation_logics.html) for list of available logics and other details.
111
+ #
112
+ #The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
113
+ #
114
+ #Logic can be also set to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
115
+ #
85
116
  # - +diversity+ -> **Expert option** Real number from [0.0, 1.0] which determines how much mutually dissimilar should the recommended items be. The default value is 0.0, i.e., no diversification. Value 1.0 means maximal diversification.
86
117
  #
87
- # - +minRelevance+ -> **Expert option** Specifies the threshold of how much 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 number of items equal to *count* at any cost. If there are not enough data (such as interactions or item properties), this may even lead to bestseller-based recommendations to be 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 relevancy, and may return less than *count* items when there is not enough data to fulfill it.
118
+ # - +minRelevance+ -> **Expert option** Specifies the threshold of how much 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 number of items equal to *count* at any cost. If there are not enough data (such as interactions or item properties), this may even lead to bestseller-based recommendations to be 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.
88
119
  #
89
120
  # - +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 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. Default: `0.1`.
90
121
  #
@@ -92,27 +123,31 @@ module RecombeeApiClient
92
123
  #
93
124
  # - +expertSettings+ -> Dictionary of custom options.
94
125
  #
126
+ # - +returnAbGroup+ -> If there is a custom AB-testing running, return name of group to which the request belongs.
127
+ #
95
128
  #
96
129
  def initialize(user_id, count, optional = {})
97
130
  @user_id = user_id
98
131
  @count = count
99
132
  optional = normalize_optional(optional)
100
- @filter = optional['filter']
101
- @booster = optional['booster']
102
- @cascade_create = optional['cascadeCreate']
103
133
  @scenario = optional['scenario']
134
+ @cascade_create = optional['cascadeCreate']
104
135
  @return_properties = optional['returnProperties']
105
136
  @included_properties = optional['includedProperties']
137
+ @filter = optional['filter']
138
+ @booster = optional['booster']
139
+ @logic = optional['logic']
106
140
  @diversity = optional['diversity']
107
141
  @min_relevance = optional['minRelevance']
108
142
  @rotation_rate = optional['rotationRate']
109
143
  @rotation_time = optional['rotationTime']
110
144
  @expert_settings = optional['expertSettings']
145
+ @return_ab_group = optional['returnAbGroup']
111
146
  @optional = optional
112
147
  @timeout = 3000
113
148
  @ensure_https = false
114
149
  @optional.each do |par, _|
115
- fail UnknownOptionalParameter.new(par) unless ["filter","booster","cascadeCreate","scenario","returnProperties","includedProperties","diversity","minRelevance","rotationRate","rotationTime","expertSettings"].include? par
150
+ fail UnknownOptionalParameter.new(par) unless ["scenario","cascadeCreate","returnProperties","includedProperties","filter","booster","logic","diversity","minRelevance","rotationRate","rotationTime","expertSettings","returnAbGroup"].include? par
116
151
  end
117
152
  end
118
153
 
@@ -125,17 +160,19 @@ module RecombeeApiClient
125
160
  def body_parameters
126
161
  p = Hash.new
127
162
  p['count'] = @count
128
- p['filter'] = @optional['filter'] if @optional.include? 'filter'
129
- p['booster'] = @optional['booster'] if @optional.include? 'booster'
130
- p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
131
163
  p['scenario'] = @optional['scenario'] if @optional.include? 'scenario'
164
+ p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
132
165
  p['returnProperties'] = @optional['returnProperties'] if @optional.include? 'returnProperties'
133
166
  p['includedProperties'] = @optional['includedProperties'] if @optional.include? 'includedProperties'
167
+ p['filter'] = @optional['filter'] if @optional.include? 'filter'
168
+ p['booster'] = @optional['booster'] if @optional.include? 'booster'
169
+ p['logic'] = @optional['logic'] if @optional.include? 'logic'
134
170
  p['diversity'] = @optional['diversity'] if @optional.include? 'diversity'
135
171
  p['minRelevance'] = @optional['minRelevance'] if @optional.include? 'minRelevance'
136
172
  p['rotationRate'] = @optional['rotationRate'] if @optional.include? 'rotationRate'
137
173
  p['rotationTime'] = @optional['rotationTime'] if @optional.include? 'rotationTime'
138
174
  p['expertSettings'] = @optional['expertSettings'] if @optional.include? 'expertSettings'
175
+ p['returnAbGroup'] = @optional['returnAbGroup'] if @optional.include? 'returnAbGroup'
139
176
  p
140
177
  end
141
178
 
@@ -0,0 +1,69 @@
1
+ #
2
+ # This file is auto-generated, do not edit
3
+ #
4
+
5
+ module RecombeeApiClient
6
+ require_relative 'request'
7
+ require_relative '../errors'
8
+
9
+ ##
10
+ #Returns items that shall be shown to a user as next recommendations when the user e.g. scrolls the page down (*infinite scroll*) or goes to a next page.
11
+ #
12
+ #It accepts `recommId` of a base recommendation request (e.g. request from the first page) and number of items that shall be returned (`count`).
13
+ #The base request can be one of:
14
+ # - [Recommend items to item](https://docs.recombee.com/api.html#recommend-items-to-item)
15
+ # - [Recommend items to user](https://docs.recombee.com/api.html#recommend-items-to-user)
16
+ # - [Search items](https://docs.recombee.com/api.html#search-items)
17
+ #
18
+ #All the other parameters are inherited from the base request.
19
+ #
20
+ #*Recommend next items* can be called many times for a single `recommId` and each call returns different (previously not recommended) items.
21
+ #The number of *Recommend next items* calls performed so far is returned in the `numberNextRecommsCalls` field.
22
+ #
23
+ #*Recommend next items* can be requested up to 30 minutes after the base request or a previous *Recommend next items* call.
24
+ #
25
+ #For billing purposes, each call to *Recommend next items* is counted as a separate recommendation request.
26
+ #
27
+ class RecommendNextItems < ApiRequest
28
+ attr_reader :recomm_id, :count
29
+ attr_accessor :timeout
30
+ attr_accessor :ensure_https
31
+
32
+ ##
33
+ # * *Required arguments*
34
+ # - +recomm_id+ -> ID of the base recommendation request for which next recommendations should be returned
35
+ # - +count+ -> Number of items to be recommended
36
+ #
37
+ #
38
+ def initialize(recomm_id, count)
39
+ @recomm_id = recomm_id
40
+ @count = count
41
+ @timeout = 3000
42
+ @ensure_https = false
43
+ end
44
+
45
+ # HTTP method
46
+ def method
47
+ :post
48
+ end
49
+
50
+ # Values of body parameters as a Hash
51
+ def body_parameters
52
+ p = Hash.new
53
+ p['count'] = @count
54
+ p
55
+ end
56
+
57
+ # Values of query parameters as a Hash.
58
+ # name of parameter => value of the parameter
59
+ def query_parameters
60
+ params = {}
61
+ params
62
+ end
63
+
64
+ # Relative path to the endpoint
65
+ def path
66
+ "/{databaseId}/recomms/next/items/#{@recomm_id}"
67
+ end
68
+ end
69
+ end
@@ -11,8 +11,10 @@ module RecombeeApiClient
11
11
  #
12
12
  #It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
13
13
  #
14
+ #The returned users are sorted by predicted interest in the item (first user being the most interested).
15
+ #
14
16
  class RecommendUsersToItem < ApiRequest
15
- attr_reader :item_id, :count, :filter, :booster, :cascade_create, :scenario, :return_properties, :included_properties, :diversity, :expert_settings
17
+ attr_reader :item_id, :count, :scenario, :cascade_create, :return_properties, :included_properties, :filter, :booster, :logic, :diversity, :expert_settings, :return_ab_group
16
18
  attr_accessor :timeout
17
19
  attr_accessor :ensure_https
18
20
 
@@ -22,10 +24,13 @@ module RecombeeApiClient
22
24
  # - +count+ -> Number of items to be recommended (N for the top-N recommendation).
23
25
  #
24
26
  # * *Optional arguments (given as hash optional)*
25
- # - +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to filter recommended items based on the values of their attributes.
26
- # - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to boost recommendation rate of some items based on the values of their attributes.
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.html) in the [Admin UI](https://admin.recombee.com). You can also see performance of each scenario in the Admin UI separately, so you can check how well each application performs.
30
+ #
31
+ #The AI which optimizes models in order to get the best results may optimize different scenarios separately, or even use different models in each of the scenarios.
32
+ #
27
33
  # - +cascadeCreate+ -> If item of given *itemId* doesn't exist in the database, it creates the missing item.
28
- # - +scenario+ -> Scenario defines a particular application of recommendations. It can be for example "homepage", "cart" or "emailing". You can see each scenario in the UI separately, so you can check how well each application performs. The AI which optimizes models in order to get the best results may optimize different scenarios separately, or even use different models in each of the scenarios.
29
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 for easy displaying the recommended users.
30
35
  #
31
36
  #Example response:
@@ -48,7 +53,8 @@ module RecombeeApiClient
48
53
  # "sex": "M"
49
54
  # }
50
55
  # }
51
- # ]
56
+ # ],
57
+ # "numberNextRecommsCalls": 0
52
58
  # }
53
59
  #```
54
60
  #
@@ -72,32 +78,52 @@ module RecombeeApiClient
72
78
  # "country": "CAN"
73
79
  # }
74
80
  # }
75
- # ]
81
+ # ],
82
+ # "numberNextRecommsCalls": 0
76
83
  # }
77
84
  #```
78
85
  #
86
+ # - +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to filter recommended items based on the values of their attributes.
87
+ #
88
+ #Filters can be also assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
89
+ #
90
+ # - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to boost recommendation rate of some items based on the values of their attributes.
91
+ #
92
+ #Boosters can be also assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
93
+ #
94
+ # - +logic+ -> Logic specifies 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.html) for 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 be also set to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
100
+ #
79
101
  # - +diversity+ -> **Expert option** Real number from [0.0, 1.0] which determines how much mutually dissimilar should the recommended items be. The default value is 0.0, i.e., no diversification. Value 1.0 means maximal diversification.
80
102
  #
81
103
  # - +expertSettings+ -> Dictionary of custom options.
82
104
  #
105
+ # - +returnAbGroup+ -> If there is a custom AB-testing running, return name of group to which the request belongs.
106
+ #
83
107
  #
84
108
  def initialize(item_id, count, optional = {})
85
109
  @item_id = item_id
86
110
  @count = count
87
111
  optional = normalize_optional(optional)
88
- @filter = optional['filter']
89
- @booster = optional['booster']
90
- @cascade_create = optional['cascadeCreate']
91
112
  @scenario = optional['scenario']
113
+ @cascade_create = optional['cascadeCreate']
92
114
  @return_properties = optional['returnProperties']
93
115
  @included_properties = optional['includedProperties']
116
+ @filter = optional['filter']
117
+ @booster = optional['booster']
118
+ @logic = optional['logic']
94
119
  @diversity = optional['diversity']
95
120
  @expert_settings = optional['expertSettings']
121
+ @return_ab_group = optional['returnAbGroup']
96
122
  @optional = optional
97
123
  @timeout = 50000
98
124
  @ensure_https = false
99
125
  @optional.each do |par, _|
100
- fail UnknownOptionalParameter.new(par) unless ["filter","booster","cascadeCreate","scenario","returnProperties","includedProperties","diversity","expertSettings"].include? par
126
+ fail UnknownOptionalParameter.new(par) unless ["scenario","cascadeCreate","returnProperties","includedProperties","filter","booster","logic","diversity","expertSettings","returnAbGroup"].include? par
101
127
  end
102
128
  end
103
129
 
@@ -110,14 +136,16 @@ module RecombeeApiClient
110
136
  def body_parameters
111
137
  p = Hash.new
112
138
  p['count'] = @count
113
- p['filter'] = @optional['filter'] if @optional.include? 'filter'
114
- p['booster'] = @optional['booster'] if @optional.include? 'booster'
115
- p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
116
139
  p['scenario'] = @optional['scenario'] if @optional.include? 'scenario'
140
+ p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
117
141
  p['returnProperties'] = @optional['returnProperties'] if @optional.include? 'returnProperties'
118
142
  p['includedProperties'] = @optional['includedProperties'] if @optional.include? 'includedProperties'
143
+ p['filter'] = @optional['filter'] if @optional.include? 'filter'
144
+ p['booster'] = @optional['booster'] if @optional.include? 'booster'
145
+ p['logic'] = @optional['logic'] if @optional.include? 'logic'
119
146
  p['diversity'] = @optional['diversity'] if @optional.include? 'diversity'
120
147
  p['expertSettings'] = @optional['expertSettings'] if @optional.include? 'expertSettings'
148
+ p['returnAbGroup'] = @optional['returnAbGroup'] if @optional.include? 'returnAbGroup'
121
149
  p
122
150
  end
123
151
 
@@ -11,21 +11,26 @@ module RecombeeApiClient
11
11
  #
12
12
  #It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
13
13
  #
14
+ #The returned users are sorted by similarity (first user being the most similar).
15
+ #
14
16
  class RecommendUsersToUser < ApiRequest
15
- attr_reader :user_id, :count, :filter, :booster, :cascade_create, :scenario, :return_properties, :included_properties, :diversity, :min_relevance, :rotation_rate, :rotation_time, :expert_settings
17
+ attr_reader :user_id, :count, :scenario, :cascade_create, :return_properties, :included_properties, :filter, :booster, :logic, :diversity, :min_relevance, :rotation_rate, :rotation_time, :expert_settings, :return_ab_group
16
18
  attr_accessor :timeout
17
19
  attr_accessor :ensure_https
18
20
 
19
21
  ##
20
22
  # * *Required arguments*
21
- # - +user_id+ -> User to which we find similar users
23
+ # - +user_id+ -> User to whom we find similar users
22
24
  # - +count+ -> Number of users to be recommended (N for the top-N recommendation).
23
25
  #
24
26
  # * *Optional arguments (given as hash optional)*
25
- # - +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to filter recommended users based on the values of their attributes.
26
- # - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to boost recommendation rate of some users based on the values of their attributes.
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.html) in the [Admin UI](https://admin.recombee.com). You can also see performance of each scenario in the Admin UI separately, so you can check how well each application performs.
30
+ #
31
+ #The AI which optimizes models in order to get the best results may optimize different scenarios separately, or even use different models in each of the scenarios.
32
+ #
27
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.
28
- # - +scenario+ -> Scenario defines a particular application of recommendations. It can be for example "homepage", "cart" or "emailing". You can see each scenario in the UI separately, so you can check how well each application performs. The AI which optimizes models in order to get the best results may optimize different scenarios separately, or even use different models in each of the scenarios.
29
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 for easy displaying the recommended users.
30
35
  #
31
36
  #Example response:
@@ -48,8 +53,9 @@ module RecombeeApiClient
48
53
  # "sex": "M"
49
54
  # }
50
55
  # }
51
- # ]
52
- # }
56
+ # ],
57
+ # "numberNextRecommsCalls": 0
58
+ # }
53
59
  #```
54
60
  #
55
61
  # - +includedProperties+ -> Allows to specify, which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list.
@@ -72,13 +78,29 @@ module RecombeeApiClient
72
78
  # "country": "CAN"
73
79
  # }
74
80
  # }
75
- # ]
81
+ # ],
82
+ # "numberNextRecommsCalls": 0
76
83
  # }
77
84
  #```
78
85
  #
86
+ # - +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to filter recommended items based on the values of their attributes.
87
+ #
88
+ #Filters can be also assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
89
+ #
90
+ # - +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to boost recommendation rate of some items based on the values of their attributes.
91
+ #
92
+ #Boosters can be also assigned to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
93
+ #
94
+ # - +logic+ -> Logic specifies 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.html) for 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 be also set to a [scenario](https://docs.recombee.com/scenarios.html) in the [Admin UI](https://admin.recombee.com).
100
+ #
79
101
  # - +diversity+ -> **Expert option** Real number from [0.0, 1.0] which determines how much mutually dissimilar should the recommended users be. The default value is 0.0, i.e., no diversification. Value 1.0 means maximal diversification.
80
102
  #
81
- # - +minRelevance+ -> **Expert option** Specifies the threshold of how much relevant must the recommended users be. Possible values one of: "low", "medium", "high". The default value is "low", meaning that the system attempts to recommend number of users equal to *count* at any cost. If there are not enough data (such as interactions or user properties), this may even lead to bestseller-based recommendations to be appended to reach the full *count*. This behavior may be suppressed by using "medium" or "high" values. In such case, the system only recommends users of at least the requested relevancy, and may return less than *count* users when there is not enough data to fulfill it.
103
+ # - +minRelevance+ -> **Expert option** Specifies the threshold of how much relevant must the recommended users be. Possible values one of: "low", "medium", "high".
82
104
  #
83
105
  # - +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 backward fashion. You may penalize an 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.
84
106
  #
@@ -86,27 +108,31 @@ module RecombeeApiClient
86
108
  #
87
109
  # - +expertSettings+ -> Dictionary of custom options.
88
110
  #
111
+ # - +returnAbGroup+ -> If there is a custom AB-testing running, return name of group to which the request belongs.
112
+ #
89
113
  #
90
114
  def initialize(user_id, count, optional = {})
91
115
  @user_id = user_id
92
116
  @count = count
93
117
  optional = normalize_optional(optional)
94
- @filter = optional['filter']
95
- @booster = optional['booster']
96
- @cascade_create = optional['cascadeCreate']
97
118
  @scenario = optional['scenario']
119
+ @cascade_create = optional['cascadeCreate']
98
120
  @return_properties = optional['returnProperties']
99
121
  @included_properties = optional['includedProperties']
122
+ @filter = optional['filter']
123
+ @booster = optional['booster']
124
+ @logic = optional['logic']
100
125
  @diversity = optional['diversity']
101
126
  @min_relevance = optional['minRelevance']
102
127
  @rotation_rate = optional['rotationRate']
103
128
  @rotation_time = optional['rotationTime']
104
129
  @expert_settings = optional['expertSettings']
130
+ @return_ab_group = optional['returnAbGroup']
105
131
  @optional = optional
106
132
  @timeout = 50000
107
133
  @ensure_https = false
108
134
  @optional.each do |par, _|
109
- fail UnknownOptionalParameter.new(par) unless ["filter","booster","cascadeCreate","scenario","returnProperties","includedProperties","diversity","minRelevance","rotationRate","rotationTime","expertSettings"].include? par
135
+ fail UnknownOptionalParameter.new(par) unless ["scenario","cascadeCreate","returnProperties","includedProperties","filter","booster","logic","diversity","minRelevance","rotationRate","rotationTime","expertSettings","returnAbGroup"].include? par
110
136
  end
111
137
  end
112
138
 
@@ -119,17 +145,19 @@ module RecombeeApiClient
119
145
  def body_parameters
120
146
  p = Hash.new
121
147
  p['count'] = @count
122
- p['filter'] = @optional['filter'] if @optional.include? 'filter'
123
- p['booster'] = @optional['booster'] if @optional.include? 'booster'
124
- p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
125
148
  p['scenario'] = @optional['scenario'] if @optional.include? 'scenario'
149
+ p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate'
126
150
  p['returnProperties'] = @optional['returnProperties'] if @optional.include? 'returnProperties'
127
151
  p['includedProperties'] = @optional['includedProperties'] if @optional.include? 'includedProperties'
152
+ p['filter'] = @optional['filter'] if @optional.include? 'filter'
153
+ p['booster'] = @optional['booster'] if @optional.include? 'booster'
154
+ p['logic'] = @optional['logic'] if @optional.include? 'logic'
128
155
  p['diversity'] = @optional['diversity'] if @optional.include? 'diversity'
129
156
  p['minRelevance'] = @optional['minRelevance'] if @optional.include? 'minRelevance'
130
157
  p['rotationRate'] = @optional['rotationRate'] if @optional.include? 'rotationRate'
131
158
  p['rotationTime'] = @optional['rotationTime'] if @optional.include? 'rotationTime'
132
159
  p['expertSettings'] = @optional['expertSettings'] if @optional.include? 'expertSettings'
160
+ p['returnAbGroup'] = @optional['returnAbGroup'] if @optional.include? 'returnAbGroup'
133
161
  p
134
162
  end
135
163