Class: RecombeeApiClient::RecommendItemSegmentsToItemSegment
- Inherits:
-
ApiRequest
- Object
- ApiRequest
- RecombeeApiClient::RecommendItemSegmentsToItemSegment
- Defined in:
- lib/recombee_api_client/api/recommend_item_segments_to_item_segment.rb
Overview
Recommends Segments from a result [Segmentation](docs.recombee.com/segmentations) that are the most relevant to a particular Segment from a context Segmentation.
Based on the used Segmentations, this endpoint can be used for example for:
- Recommending the related brands to particular brand
- Recommending the related brands to particular category
- Recommending the related artists to a particular genre (assuming songs are the Items)
You need to set the used context and result Segmentation the Admin UI in the [Scenario settings](docs.recombee.com/scenarios) 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.
-
#context_segment_id ⇒ Object
readonly
Returns the value of attribute context_segment_id.
-
#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.
-
#return_ab_group ⇒ Object
readonly
Returns the value of attribute return_ab_group.
-
#scenario ⇒ Object
readonly
Returns the value of attribute scenario.
-
#target_user_id ⇒ Object
readonly
Returns the value of attribute target_user_id.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
-
#body_parameters ⇒ Object
Values of body parameters as a Hash.
-
#initialize(context_segment_id, target_user_id, count, optional = {}) ⇒ RecommendItemSegmentsToItemSegment
constructor
-
*Required arguments* -
context_segment_id
-> ID of the segment from ‘contextSegmentationId` for which the recommendations are to be generated.
-
-
#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_optional
Constructor Details
#initialize(context_segment_id, target_user_id, count, optional = {}) ⇒ RecommendItemSegmentsToItemSegment
-
*Required arguments*
-
context_segment_id
-> ID of the segment from ‘contextSegmentationId` for which the recommendations are to be generated. -
target_user_id
-> ID of the user who will see the recommendations.
-
Specifying the targetUserId is beneficial because:
-
It makes the recommendations personalized
-
Allows the calculation of Actions and Conversions
in the graphical user interface,
as Recombee can pair the user who got recommendations
and who afterward viewed/purchased an item.
If you insist on not specifying the user, pass ‘null` (`None`, `nil`, `NULL` etc., depending on the language) to targetUserId. Do not create some special dummy user for getting recommendations, as it could mislead the recommendation models, and result in wrong recommendations.
For anonymous/unregistered users, it is possible to use, for example, their session ID.
- +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](docs.recombee.com/scenarios) in the [Admin UI](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.
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](docs.recombee.com/recommendation_logics) 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](docs.recombee.com/scenarios) in the [Admin UI](admin.recombee.com).
- +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.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/recombee_api_client/api/recommend_item_segments_to_item_segment.rb', line 78 def initialize(context_segment_id, target_user_id, count, optional = {}) @context_segment_id = context_segment_id @target_user_id = target_user_id @count = count optional = normalize_optional(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'] @optional = optional @timeout = 3000 @ensure_https = false @optional.each do |par, _| fail UnknownOptionalParameter.new(par) unless ["scenario","cascadeCreate","filter","booster","logic","expertSettings","returnAbGroup"].include? par end end |
Instance Attribute Details
#booster ⇒ Object (readonly)
Returns the value of attribute booster.
25 26 27 |
# File 'lib/recombee_api_client/api/recommend_item_segments_to_item_segment.rb', line 25 def booster @booster end |
#cascade_create ⇒ Object (readonly)
Returns the value of attribute cascade_create.
25 26 27 |
# File 'lib/recombee_api_client/api/recommend_item_segments_to_item_segment.rb', line 25 def cascade_create @cascade_create end |
#context_segment_id ⇒ Object (readonly)
Returns the value of attribute context_segment_id.
25 26 27 |
# File 'lib/recombee_api_client/api/recommend_item_segments_to_item_segment.rb', line 25 def context_segment_id @context_segment_id end |
#count ⇒ Object (readonly)
Returns the value of attribute count.
25 26 27 |
# File 'lib/recombee_api_client/api/recommend_item_segments_to_item_segment.rb', line 25 def count @count end |
#ensure_https ⇒ Object
Returns the value of attribute ensure_https.
27 28 29 |
# File 'lib/recombee_api_client/api/recommend_item_segments_to_item_segment.rb', line 27 def ensure_https @ensure_https end |
#expert_settings ⇒ Object (readonly)
Returns the value of attribute expert_settings.
25 26 27 |
# File 'lib/recombee_api_client/api/recommend_item_segments_to_item_segment.rb', line 25 def expert_settings @expert_settings end |
#filter ⇒ Object (readonly)
Returns the value of attribute filter.
25 26 27 |
# File 'lib/recombee_api_client/api/recommend_item_segments_to_item_segment.rb', line 25 def filter @filter end |
#logic ⇒ Object (readonly)
Returns the value of attribute logic.
25 26 27 |
# File 'lib/recombee_api_client/api/recommend_item_segments_to_item_segment.rb', line 25 def logic @logic end |
#return_ab_group ⇒ Object (readonly)
Returns the value of attribute return_ab_group.
25 26 27 |
# File 'lib/recombee_api_client/api/recommend_item_segments_to_item_segment.rb', line 25 def return_ab_group @return_ab_group end |
#scenario ⇒ Object (readonly)
Returns the value of attribute scenario.
25 26 27 |
# File 'lib/recombee_api_client/api/recommend_item_segments_to_item_segment.rb', line 25 def scenario @scenario end |
#target_user_id ⇒ Object (readonly)
Returns the value of attribute target_user_id.
25 26 27 |
# File 'lib/recombee_api_client/api/recommend_item_segments_to_item_segment.rb', line 25 def target_user_id @target_user_id end |
#timeout ⇒ Object
Returns the value of attribute timeout.
26 27 28 |
# File 'lib/recombee_api_client/api/recommend_item_segments_to_item_segment.rb', line 26 def timeout @timeout end |
Instance Method Details
#body_parameters ⇒ Object
Values of body parameters as a Hash
104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/recombee_api_client/api/recommend_item_segments_to_item_segment.rb', line 104 def body_parameters p = Hash.new p['contextSegmentId'] = @context_segment_id p['targetUserId'] = @target_user_id 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 end |
#method ⇒ Object
HTTP method
99 100 101 |
# File 'lib/recombee_api_client/api/recommend_item_segments_to_item_segment.rb', line 99 def method :post end |
#path ⇒ Object
Relative path to the endpoint
127 128 129 |
# File 'lib/recombee_api_client/api/recommend_item_segments_to_item_segment.rb', line 127 def path "/{databaseId}/recomms/item-segments/item-segments/" end |
#query_parameters ⇒ Object
Values of query parameters as a Hash. name of parameter => value of the parameter
121 122 123 124 |
# File 'lib/recombee_api_client/api/recommend_item_segments_to_item_segment.rb', line 121 def query_parameters params = {} params end |