Skip to content

Commit

Permalink
Support image and imageList item property types
Browse files Browse the repository at this point in the history
  • Loading branch information
OndraFiedler committed Apr 5, 2018
1 parent 896aada commit 60dfb42
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 22 deletions.
5 changes: 4 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,17 @@ Using property values
client.send(ResetDatabase())
# We will use computers as items in this example
# Computers have three properties
# Computers have four properties
# - price (floating point number)
# - number of processor cores (integer number)
# - description (string)
# - image (url of computer's photo)
# Add properties of items
client.send(AddItemProperty('price', 'double'))
client.send(AddItemProperty('num-cores', 'int'))
client.send(AddItemProperty('description', 'string'))
client.send(AddItemProperty('image', 'image'))
# Prepare requests for setting a catalog of computers
requests = [SetItemValues(
Expand All @@ -101,6 +103,7 @@ Using property values
'price': random.uniform(500, 2000),
'num-cores': random.randrange(1,9),
'description': 'Great computer',
'image': 'http://examplesite.com/products/computer-%s.jpg' % i
},
cascade_create=True # Use cascadeCreate for creating item
# with given itemId if it doesn't exist
Expand Down
2 changes: 1 addition & 1 deletion recombee_api_client/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def send(self, request):

@staticmethod
def __get_http_headers(additional_headers=None):
headers = {'User-Agent': 'recombee-python-api-client/2.0.0'}
headers = {'User-Agent': 'recombee-python-api-client/2.1.0'}
if additional_headers:
headers.update(additional_headers)
return headers
Expand Down
2 changes: 1 addition & 1 deletion recombee_api_client/api_requests/add_item_property.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __init__(self, property_name, type):
@param property_name: Name of the item property to be created. Currently, the following names are reserved:`id`, `itemid`, case insensitively. Also, the length of the property name must not exceed 63 characters.
@param type: Value type of the item property to be created. One of: `int`, `double`, `string`, `boolean`, `timestamp`, `set`
@param type: Value type of the item property to be created. One of: `int`, `double`, `string`, `boolean`, `timestamp`, `set`, `image` or `imageList`.
"""
Expand Down
2 changes: 0 additions & 2 deletions recombee_api_client/api_requests/delete_view_portion.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

class DeleteViewPortion(Request):
"""
The view portions feature is currently experimental.
Deletes an existing view portion specified by (`userId`, `itemId`, `sessionId`) from the database.
"""
Expand Down
4 changes: 2 additions & 2 deletions recombee_api_client/api_requests/item_based_recommendation.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ def __init__(self, item_id, count, target_user_id=DEFAULT, user_impact=DEFAULT,
@param min_relevance: **Expert option** If the *targetUserId* is provided: 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 qualit, and may return less than *count* items when there is not enough data to fulfill it.
@param rotation_rate: **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 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.
@param rotation_rate: **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 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.01`.
@param rotation_time: **Expert option** If the *targetUserId* is provided: Taking *rotationRate* into account, specifies how long time it takes to an item to recover from the penalization. For example, `rotationTime=7200.0` means that items recommended less than 2 hours ago are penalized.
@param rotation_time: **Expert option** If the *targetUserId* is provided: Taking *rotationRate* into account, specifies how long time it takes to an item to recover from the penalization. For example, `rotationTime=7200.0` means that items recommended less than 2 hours ago are penalized. Default: `7200.0`.
@param expert_settings: Dictionary of custom options.
Expand Down
2 changes: 0 additions & 2 deletions recombee_api_client/api_requests/list_item_view_portions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

class ListItemViewPortions(Request):
"""
The view portions feature is currently experimental.
List all the view portions of an item ever submitted by different users.
"""
Expand Down
2 changes: 0 additions & 2 deletions recombee_api_client/api_requests/list_user_view_portions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

class ListUserViewPortions(Request):
"""
The view portions feature is currently experimental.
List all the view portions ever submitted by a given user.
"""
Expand Down
4 changes: 2 additions & 2 deletions recombee_api_client/api_requests/merge_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ class MergeUsers(Request):
def __init__(self, target_user_id, source_user_id, cascade_create=DEFAULT):
"""
Required parameters:
@param target_user_id: ID of the source user.
@param target_user_id: ID of the targer user.
@param source_user_id: ID of the target user.
@param source_user_id: ID of the source user.
Optional parameters:
Expand Down
4 changes: 2 additions & 2 deletions recombee_api_client/api_requests/recommend_items_to_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ def __init__(self, user_id, count, filter=DEFAULT, booster=DEFAULT, cascade_crea
@param min_relevance: **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.
@param rotation_rate: **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.
@param rotation_rate: **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`.
@param rotation_time: **Expert option** Taking *rotationRate* into account, specifies how long time it takes to an item to recover from the penalization. For example, `rotationTime=7200.0` means that items recommended less than 2 hours ago are penalized.
@param rotation_time: **Expert option** Taking *rotationRate* into account, specifies how long time it takes to an item to recover from the penalization. For example, `rotationTime=7200.0` means that items recommended less than 2 hours ago are penalized. Default: `7200.0`.
@param expert_settings: Dictionary of custom options.
Expand Down
6 changes: 2 additions & 4 deletions recombee_api_client/api_requests/set_view_portion.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

class SetViewPortion(Request):
"""
The view portions feature is currently experimental.
Sets viewed portion of an item (for example a video or article) by a user (at a session).
If you send new request with the same (`userId`, `itemId`, `sessionId`), the portion gets updated.
Expand All @@ -19,11 +17,11 @@ def __init__(self, user_id, item_id, portion, session_id=DEFAULT, timestamp=DEFA
@param item_id: Viewed item
@param portion: Viewed portion of the item (number between 0.0 (viewed nothing) and 1.0 (viewed full item) ).
@param portion: Viewed portion of the item (number between 0.0 (viewed nothing) and 1.0 (viewed full item) ). It should be the really viewed part of the item, no matter seeking, so for example if the user seeked immediately to half of the item and then viewed 10% of the item, the `portion` should still be `0.1`.
Optional parameters:
@param session_id: Id of session in which the user viewed the item
@param session_id: ID of session in which the user viewed the item. Default is `null` (`None`, `nil`, `NULL` etc. depending on language).
@param timestamp: UTC timestamp of the rating as ISO8601-1 pattern or UTC epoch time. The default value is the current time.
Expand Down
4 changes: 2 additions & 2 deletions recombee_api_client/api_requests/user_based_recommendation.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ def __init__(self, user_id, count, filter=DEFAULT, booster=DEFAULT, allow_nonexi
@param min_relevance: **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 qualit, and may return less than *count* items when there is not enough data to fulfill it.
@param rotation_rate: **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.
@param rotation_rate: **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`.
@param rotation_time: **Expert option** Taking *rotationRate* into account, specifies how long time it takes to an item to recover from the penalization. For example, `rotationTime=7200.0` means that items recommended less than 2 hours ago are penalized.
@param rotation_time: **Expert option** Taking *rotationRate* into account, specifies how long time it takes to an item to recover from the penalization. For example, `rotationTime=7200.0` means that items recommended less than 2 hours ago are penalized. Default: `7200.0`.
@param expert_settings: Dictionary of custom options.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
setup(
name='recombee-api-client',

version='2.0.0',
version='2.1.0',

description='Client for Recombee recommendation API',
long_description=long_description,
Expand Down

0 comments on commit 60dfb42

Please sign in to comment.