Class: RecombeeApiClient::RecommendItemSegmentsToUser
- Inherits:
-
ApiRequest
- Object
- ApiRequest
- RecombeeApiClient::RecommendItemSegmentsToUser
- Defined in:
- lib/recombee_api_client/api/recommend_item_segments_to_user.rb
Overview
Recommends the top Segments from a Segmentation for a particular user, based on the user's past interactions.
Based on the used Segmentation, this endpoint can be used for example for:
- Recommending the top categories for the user
- Recommending the top genres for the user
- Recommending the top brands for the user
- Recommending the top artists for the user
You need to set the used Segmentation the Admin UI in the Scenario settings prior to using this endpoint.
The returned segments are sorted by relevance (first segment being the most relevant).
It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.
Instance Attribute Summary collapse
-
#booster ⇒ Object
readonly
Returns the value of attribute booster.
-
#cascade_create ⇒ Object
readonly
Returns the value of attribute cascade_create.
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#ensure_https ⇒ Object
Returns the value of attribute ensure_https.
-
#expert_settings ⇒ Object
readonly
Returns the value of attribute expert_settings.
-
#filter ⇒ Object
readonly
Returns the value of attribute filter.
-
#logic ⇒ Object
readonly
Returns the value of attribute logic.
-
#reql_expressions ⇒ Object
readonly
Returns the value of attribute reql_expressions.
-
#return_ab_group ⇒ Object
readonly
Returns the value of attribute return_ab_group.
-
#scenario ⇒ Object
readonly
Returns the value of attribute scenario.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#user_id ⇒ Object
readonly
Returns the value of attribute user_id.
Instance Method Summary collapse
-
#body_parameters ⇒ Object
Values of body parameters as a Hash.
-
#initialize(user_id, count, optional = {}) ⇒ RecommendItemSegmentsToUser
constructor
- Required arguments -
user_id-> ID of the user for whom personalized recommendations are to be generated.
- Required arguments -
-
#method ⇒ Object
HTTP method.
-
#path ⇒ Object
Relative path to the endpoint.
-
#query_parameters ⇒ Object
Values of query parameters as a Hash.
Methods included from HashNormalizer
#camelize, #normalize_hash_to_camel_case
Constructor Details
#initialize(user_id, count, optional = {}) ⇒ RecommendItemSegmentsToUser
-
Required arguments
user_id-> ID of the user for whom personalized recommendations are to be generated.count-> Number of item segments to be recommended (N for the top-N recommendation).
-
Optional arguments (given as hash optional)
scenario-> Scenario defines a particular application of recommendations. It can be, for example, "homepage", "cart", or "emailing".
You can set various settings to the scenario in the Admin UI. You can also see the performance of each scenario in the Admin UI separately, so you can check how well each application performs.
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.
- +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.
- +filter+ -> Boolean-returning [ReQL](https://docs.recombee.com/reql) expression which allows you to filter recommended segments based on the `segmentationId`.
- +booster+ -> Number-returning [ReQL](https://docs.recombee.com/reql) expression which allows you to boost recommendation rate of some segments based on the `segmentationId`.
- +logic+ -> Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case.
See this section for a list of available logics and other details.
The difference between logic and scenario is that logic specifies mainly behavior, while scenario specifies the place where recommendations are shown to the users.
Logic can also be set to a scenario in the Admin UI.
- +expertSettings+ -> Dictionary of custom options.
- +returnAbGroup+ -> If there is a custom AB-testing running, return the name of the group to which the request belongs.
- +reqlExpressions+ -> A dictionary of [ReQL](https://docs.recombee.com/reql) expressions that will be executed for each recommended Item Segment.
This can be used to compute additional properties of the recommended Item Segments.
The keys are the names of the expressions, and the values are the actual ReQL expressions.
Example request:
{
"reqlExpressions": {
"countItems": "size(segment_items(\"categories\", 'segmentId'))"
}
}
Example response:
{
"recommId": "a7ac55a4-8d6e-4f19-addc-abac4164d8a8",
"recomms":
[
{
"id": "category-fantasy-books",
"reqlEvaluations": {
"countItems": 486
}
},
{
"id": "category-sci-fi-costumes",
"reqlEvaluations": {
"countItems": 19
}
}
],
"numberNextRecommsCalls": 0
}
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/recombee_api_client/api/recommend_item_segments_to_user.rb', line 98 def initialize(user_id, count, optional = {}) @user_id = user_id @count = count optional = normalize_hash_to_camel_case(optional) @scenario = optional['scenario'] @cascade_create = optional['cascadeCreate'] @filter = optional['filter'] @booster = optional['booster'] @logic = optional['logic'] @expert_settings = optional['expertSettings'] @return_ab_group = optional['returnAbGroup'] @reql_expressions = optional['reqlExpressions'] @optional = optional @timeout = 3000 @ensure_https = false @optional.each do |par, _| raise UnknownOptionalParameter.new(par) unless %w[scenario cascadeCreate filter booster logic expertSettings returnAbGroup reqlExpressions].include? par end end |
Instance Attribute Details
#booster ⇒ Object (readonly)
Returns the value of attribute booster.
26 27 28 |
# File 'lib/recombee_api_client/api/recommend_item_segments_to_user.rb', line 26 def booster @booster end |
#cascade_create ⇒ Object (readonly)
Returns the value of attribute cascade_create.
26 27 28 |
# File 'lib/recombee_api_client/api/recommend_item_segments_to_user.rb', line 26 def cascade_create @cascade_create end |
#count ⇒ Object (readonly)
Returns the value of attribute count.
26 27 28 |
# File 'lib/recombee_api_client/api/recommend_item_segments_to_user.rb', line 26 def count @count end |
#ensure_https ⇒ Object
Returns the value of attribute ensure_https.
28 29 30 |
# File 'lib/recombee_api_client/api/recommend_item_segments_to_user.rb', line 28 def ensure_https @ensure_https end |
#expert_settings ⇒ Object (readonly)
Returns the value of attribute expert_settings.
26 27 28 |
# File 'lib/recombee_api_client/api/recommend_item_segments_to_user.rb', line 26 def expert_settings @expert_settings end |
#filter ⇒ Object (readonly)
Returns the value of attribute filter.
26 27 28 |
# File 'lib/recombee_api_client/api/recommend_item_segments_to_user.rb', line 26 def filter @filter end |
#logic ⇒ Object (readonly)
Returns the value of attribute logic.
26 27 28 |
# File 'lib/recombee_api_client/api/recommend_item_segments_to_user.rb', line 26 def logic @logic end |
#reql_expressions ⇒ Object (readonly)
Returns the value of attribute reql_expressions.
26 27 28 |
# File 'lib/recombee_api_client/api/recommend_item_segments_to_user.rb', line 26 def reql_expressions @reql_expressions end |
#return_ab_group ⇒ Object (readonly)
Returns the value of attribute return_ab_group.
26 27 28 |
# File 'lib/recombee_api_client/api/recommend_item_segments_to_user.rb', line 26 def return_ab_group @return_ab_group end |
#scenario ⇒ Object (readonly)
Returns the value of attribute scenario.
26 27 28 |
# File 'lib/recombee_api_client/api/recommend_item_segments_to_user.rb', line 26 def scenario @scenario end |
#timeout ⇒ Object
Returns the value of attribute timeout.
28 29 30 |
# File 'lib/recombee_api_client/api/recommend_item_segments_to_user.rb', line 28 def timeout @timeout end |
#user_id ⇒ Object (readonly)
Returns the value of attribute user_id.
26 27 28 |
# File 'lib/recombee_api_client/api/recommend_item_segments_to_user.rb', line 26 def user_id @user_id end |
Instance Method Details
#body_parameters ⇒ Object
Values of body parameters as a Hash
125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/recombee_api_client/api/recommend_item_segments_to_user.rb', line 125 def body_parameters p = {} p['count'] = @count p['scenario'] = @optional['scenario'] if @optional.include? 'scenario' p['cascadeCreate'] = @optional['cascadeCreate'] if @optional.include? 'cascadeCreate' p['filter'] = @optional['filter'] if @optional.include? 'filter' p['booster'] = @optional['booster'] if @optional.include? 'booster' p['logic'] = @optional['logic'] if @optional.include? 'logic' p['expertSettings'] = @optional['expertSettings'] if @optional.include? 'expertSettings' p['returnAbGroup'] = @optional['returnAbGroup'] if @optional.include? 'returnAbGroup' p['reqlExpressions'] = @optional['reqlExpressions'] if @optional.include? 'reqlExpressions' p end |
#method ⇒ Object
HTTP method
120 121 122 |
# File 'lib/recombee_api_client/api/recommend_item_segments_to_user.rb', line 120 def method :post end |
#path ⇒ Object
Relative path to the endpoint
147 148 149 |
# File 'lib/recombee_api_client/api/recommend_item_segments_to_user.rb', line 147 def path "/{databaseId}/recomms/users/#{@user_id}/item-segments/" end |
#query_parameters ⇒ Object
Values of query parameters as a Hash. name of parameter => value of the parameter
142 143 144 |
# File 'lib/recombee_api_client/api/recommend_item_segments_to_user.rb', line 142 def query_parameters {} end |