Dataset Viewer
Duplicate
The dataset viewer is not available for this split.
Cannot load the dataset split (in streaming mode) to extract the first rows.
Error code:   StreamingRowsError
Exception:    CastError
Message:      Couldn't cast
digest: string
kind: string
path: string
payload_sha3: string
prev: string
seq: int64
ts: timestamp[s]
all_passed: bool
python: string
schema: string
failed_ids: list<item: null>
  child 0, item: null
version: string
source: struct<git: struct<doc_only: bool, head: string, url: string, branch: string, sha_verified_from: str (... 5 chars omitted)
  child 0, git: struct<doc_only: bool, head: string, url: string, branch: string, sha_verified_from: string>
      child 0, doc_only: bool
      child 1, head: string
      child 2, url: string
      child 3, branch: string
      child 4, sha_verified_from: string
method: struct<aggregate_rule: string, excluded: string, reproduce: string, thresholds_note: string>
  child 0, aggregate_rule: string
  child 1, excluded: string
  child 2, reproduce: string
  child 3, thresholds_note: string
total: int64
failed: int64
benchmarks: list<item: struct<evidence: struct<ceilings: struct<max_files: int64, max_lines: int64, min_lines: i (... 3044 chars omitted)
  child 0, item: struct<evidence: struct<ceilings: struct<max_files: int64, max_lines: int64, min_lines: int64>, code (... 3032 chars omitted)
      child 0, evidence: struct<ceilings: struct<max_files: int64, max_lines: int64, min_lines: int64>, code_lines: int64, co (... 2961 chars omitted)
          child 0, ceilings: struct<max_files: int64, max_lines: int64, min_lines: int64>
              child 0, max_files: int64
              child 1, max_lines: int64
              child 2, min_line
...
pinned: struct<detail: string, evidence_path: string, present: bool>
                  child 0, detail: string
                  child 1, evidence_path: string
                  child 2, present: bool
              child 5, reproducible_tests: struct<detail: string, evidence_path: string, present: bool>
                  child 0, detail: string
                  child 1, evidence_path: string
                  child 2, present: bool
              child 6, rerunnable_verification: struct<detail: string, evidence_path: string, present: bool>
                  child 0, detail: string
                  child 1, evidence_path: string
                  child 2, present: bool
              child 7, versioning: struct<detail: string, evidence_path: string, present: bool>
                  child 0, detail: string
                  child 1, evidence_path: string
                  child 2, present: bool
          child 62, criteria_missing: list<item: null>
              child 0, item: null
          child 63, criteria_satisfied: int64
          child 64, criteria_total: int64
          child 65, framework_controls_verified: int64
          child 66, ladder: string
          child 67, observed_level: int64
          child 68, source: string
          child 69, trL9_claimed: bool
          child 70, trL9_reason: string
      child 1, id: string
      child 2, ok: bool
      child 3, status: string
      child 4, title: string
root: string
sbom_written: bool
platform: string
passed: int64
to
{'all_passed': Value('bool'), 'benchmarks': List({'evidence': {'ceilings': {'max_files': Value('int64'), 'max_lines': Value('int64'), 'min_lines': Value('int64')}, 'code_lines': Value('int64'), 'command': Value('string'), 'counts_command': Value('string'), 'files_source': Value('int64'), 'files_tests': Value('int64'), 'files_total': Value('int64'), 'method': Value('string'), 'test_to_source_line_ratio': Value('float64'), 'total_lines': Value('int64'), 'a_licences': List(Value('string')), 'b_licences': List(Value('string')), 'default_for_unknown_is_C': Value('bool'), 'mismatches': {}, 'observed': {'agpl3': Value('string'), 'apache2': Value('string'), 'bsd3': Value('string'), 'commons_clause': Value('string'), 'garbage': Value('string'), 'gpl3': Value('string'), 'isc': Value('string'), 'lgpl': Value('string'), 'mit': Value('string'), 'mpl2': Value('string'), 'noncommercial': Value('string'), 'proprietary': Value('string'), 'sspl': Value('string'), 'unknown_absent': Value('string')}, 'only_class_A_may_relicense': Value('bool'), 'policy_probes': {'agpl3': Value('string'), 'apache2': Value('string'), 'bsd3': Value('string'), 'commons_clause': Value('string'), 'garbage': Value('string'), 'gpl3': Value('string'), 'isc': Value('string'), 'lgpl': Value('string'), 'mit': Value('string'), 'mpl2': Value('string'), 'noncommercial': Value('string'), 'proprietary': Value('string'), 'sspl': Value('string'), 'unknown_absent': Value('string')}, 'project_licence': {'LICENSE': Value('string'), '
...
path': Value('string'), 'present': Value('bool')}, 'qualification_environment_pinned': {'detail': Value('string'), 'evidence_path': Value('string'), 'present': Value('bool')}, 'reproducible_tests': {'detail': Value('string'), 'evidence_path': Value('string'), 'present': Value('bool')}, 'rerunnable_verification': {'detail': Value('string'), 'evidence_path': Value('string'), 'present': Value('bool')}, 'versioning': {'detail': Value('string'), 'evidence_path': Value('string'), 'present': Value('bool')}}, 'criteria_missing': List(Value('null')), 'criteria_satisfied': Value('int64'), 'criteria_total': Value('int64'), 'framework_controls_verified': Value('int64'), 'ladder': Value('string'), 'observed_level': Value('int64'), 'source': Value('string'), 'trL9_claimed': Value('bool'), 'trL9_reason': Value('string')}, 'id': Value('string'), 'ok': Value('bool'), 'status': Value('string'), 'title': Value('string')}), 'failed': Value('int64'), 'failed_ids': List(Value('null')), 'method': {'aggregate_rule': Value('string'), 'excluded': Value('string'), 'reproduce': Value('string'), 'thresholds_note': Value('string')}, 'passed': Value('int64'), 'platform': Value('string'), 'python': Value('string'), 'root': Value('string'), 'sbom_written': Value('bool'), 'schema': Value('string'), 'total': Value('int64'), 'version': Value('string'), 'source': {'git': {'doc_only': Value('bool'), 'head': Value('string'), 'url': Value('string'), 'branch': Value('string'), 'sha_verified_from': Value('string')}}}
because column names don't match
Traceback:    Traceback (most recent call last):
                File "/src/services/worker/src/worker/utils.py", line 147, in get_rows_or_raise
                  return get_rows(
                      dataset=dataset,
                  ...<4 lines>...
                      column_names=column_names,
                  )
                File "/src/libs/libcommon/src/libcommon/utils.py", line 272, in decorator
                  return func(*args, **kwargs)
                File "/src/services/worker/src/worker/utils.py", line 127, in get_rows
                  rows_plus_one = list(itertools.islice(safe_iter(ds, dataset=dataset), rows_max_number + 1))
                File "/src/services/worker/src/worker/utils.py", line 483, in safe_iter
                  yield from ds.decode(False) if ds.features else ds
                File "/usr/local/lib/python3.14/site-packages/datasets/iterable_dataset.py", line 2951, in __iter__
                  for key, example in ex_iterable:
                                      ^^^^^^^^^^^
                File "/usr/local/lib/python3.14/site-packages/datasets/iterable_dataset.py", line 2461, in __iter__
                  for key, pa_table in self._iter_arrow():
                                       ~~~~~~~~~~~~~~~~^^
                File "/usr/local/lib/python3.14/site-packages/datasets/iterable_dataset.py", line 2486, in _iter_arrow
                  for key, pa_table in self.ex_iterable._iter_arrow():
                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
                File "/usr/local/lib/python3.14/site-packages/datasets/iterable_dataset.py", line 547, in _iter_arrow
                  for key, pa_table in iterator:
                                       ^^^^^^^^
                File "/usr/local/lib/python3.14/site-packages/datasets/iterable_dataset.py", line 430, in _iter_arrow
                  for key, pa_table in self.generate_tables_fn(**gen_kwags):
                                       ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
                File "/usr/local/lib/python3.14/site-packages/datasets/packaged_modules/json/json.py", line 343, in _generate_tables
                  self._cast_table(pa_table, json_field_paths=json_field_paths),
                  ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                File "/usr/local/lib/python3.14/site-packages/datasets/packaged_modules/json/json.py", line 132, in _cast_table
                  pa_table = table_cast(pa_table, self.info.features.arrow_schema)
                File "/usr/local/lib/python3.14/site-packages/datasets/table.py", line 2378, in table_cast
                  return cast_table_to_schema(table, schema)
                File "/usr/local/lib/python3.14/site-packages/datasets/table.py", line 2306, in cast_table_to_schema
                  raise CastError(
                  ...<3 lines>...
                  )
              datasets.table.CastError: Couldn't cast
              digest: string
              kind: string
              path: string
              payload_sha3: string
              prev: string
              seq: int64
              ts: timestamp[s]
              all_passed: bool
              python: string
              schema: string
              failed_ids: list<item: null>
                child 0, item: null
              version: string
              source: struct<git: struct<doc_only: bool, head: string, url: string, branch: string, sha_verified_from: str (... 5 chars omitted)
                child 0, git: struct<doc_only: bool, head: string, url: string, branch: string, sha_verified_from: string>
                    child 0, doc_only: bool
                    child 1, head: string
                    child 2, url: string
                    child 3, branch: string
                    child 4, sha_verified_from: string
              method: struct<aggregate_rule: string, excluded: string, reproduce: string, thresholds_note: string>
                child 0, aggregate_rule: string
                child 1, excluded: string
                child 2, reproduce: string
                child 3, thresholds_note: string
              total: int64
              failed: int64
              benchmarks: list<item: struct<evidence: struct<ceilings: struct<max_files: int64, max_lines: int64, min_lines: i (... 3044 chars omitted)
                child 0, item: struct<evidence: struct<ceilings: struct<max_files: int64, max_lines: int64, min_lines: int64>, code (... 3032 chars omitted)
                    child 0, evidence: struct<ceilings: struct<max_files: int64, max_lines: int64, min_lines: int64>, code_lines: int64, co (... 2961 chars omitted)
                        child 0, ceilings: struct<max_files: int64, max_lines: int64, min_lines: int64>
                            child 0, max_files: int64
                            child 1, max_lines: int64
                            child 2, min_line
              ...
              pinned: struct<detail: string, evidence_path: string, present: bool>
                                child 0, detail: string
                                child 1, evidence_path: string
                                child 2, present: bool
                            child 5, reproducible_tests: struct<detail: string, evidence_path: string, present: bool>
                                child 0, detail: string
                                child 1, evidence_path: string
                                child 2, present: bool
                            child 6, rerunnable_verification: struct<detail: string, evidence_path: string, present: bool>
                                child 0, detail: string
                                child 1, evidence_path: string
                                child 2, present: bool
                            child 7, versioning: struct<detail: string, evidence_path: string, present: bool>
                                child 0, detail: string
                                child 1, evidence_path: string
                                child 2, present: bool
                        child 62, criteria_missing: list<item: null>
                            child 0, item: null
                        child 63, criteria_satisfied: int64
                        child 64, criteria_total: int64
                        child 65, framework_controls_verified: int64
                        child 66, ladder: string
                        child 67, observed_level: int64
                        child 68, source: string
                        child 69, trL9_claimed: bool
                        child 70, trL9_reason: string
                    child 1, id: string
                    child 2, ok: bool
                    child 3, status: string
                    child 4, title: string
              root: string
              sbom_written: bool
              platform: string
              passed: int64
              to
              {'all_passed': Value('bool'), 'benchmarks': List({'evidence': {'ceilings': {'max_files': Value('int64'), 'max_lines': Value('int64'), 'min_lines': Value('int64')}, 'code_lines': Value('int64'), 'command': Value('string'), 'counts_command': Value('string'), 'files_source': Value('int64'), 'files_tests': Value('int64'), 'files_total': Value('int64'), 'method': Value('string'), 'test_to_source_line_ratio': Value('float64'), 'total_lines': Value('int64'), 'a_licences': List(Value('string')), 'b_licences': List(Value('string')), 'default_for_unknown_is_C': Value('bool'), 'mismatches': {}, 'observed': {'agpl3': Value('string'), 'apache2': Value('string'), 'bsd3': Value('string'), 'commons_clause': Value('string'), 'garbage': Value('string'), 'gpl3': Value('string'), 'isc': Value('string'), 'lgpl': Value('string'), 'mit': Value('string'), 'mpl2': Value('string'), 'noncommercial': Value('string'), 'proprietary': Value('string'), 'sspl': Value('string'), 'unknown_absent': Value('string')}, 'only_class_A_may_relicense': Value('bool'), 'policy_probes': {'agpl3': Value('string'), 'apache2': Value('string'), 'bsd3': Value('string'), 'commons_clause': Value('string'), 'garbage': Value('string'), 'gpl3': Value('string'), 'isc': Value('string'), 'lgpl': Value('string'), 'mit': Value('string'), 'mpl2': Value('string'), 'noncommercial': Value('string'), 'proprietary': Value('string'), 'sspl': Value('string'), 'unknown_absent': Value('string')}, 'project_licence': {'LICENSE': Value('string'), '
              ...
              path': Value('string'), 'present': Value('bool')}, 'qualification_environment_pinned': {'detail': Value('string'), 'evidence_path': Value('string'), 'present': Value('bool')}, 'reproducible_tests': {'detail': Value('string'), 'evidence_path': Value('string'), 'present': Value('bool')}, 'rerunnable_verification': {'detail': Value('string'), 'evidence_path': Value('string'), 'present': Value('bool')}, 'versioning': {'detail': Value('string'), 'evidence_path': Value('string'), 'present': Value('bool')}}, 'criteria_missing': List(Value('null')), 'criteria_satisfied': Value('int64'), 'criteria_total': Value('int64'), 'framework_controls_verified': Value('int64'), 'ladder': Value('string'), 'observed_level': Value('int64'), 'source': Value('string'), 'trL9_claimed': Value('bool'), 'trL9_reason': Value('string')}, 'id': Value('string'), 'ok': Value('bool'), 'status': Value('string'), 'title': Value('string')}), 'failed': Value('int64'), 'failed_ids': List(Value('null')), 'method': {'aggregate_rule': Value('string'), 'excluded': Value('string'), 'reproduce': Value('string'), 'thresholds_note': Value('string')}, 'passed': Value('int64'), 'platform': Value('string'), 'python': Value('string'), 'root': Value('string'), 'sbom_written': Value('bool'), 'schema': Value('string'), 'total': Value('int64'), 'version': Value('string'), 'source': {'git': {'doc_only': Value('bool'), 'head': Value('string'), 'url': Value('string'), 'branch': Value('string'), 'sha_verified_from': Value('string')}}}
              because column names don't match

Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.

YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

PYTHON_API_CLIENT_PRIOR_DOCS

licence offline-first audit checks

Governed Anticloud packaging of the upstream project PYTHON_API_CLIENT_PRIOR_DOCS in category ONLINE_RETAIL. check results: see ISOLATED_LAB_RESULTS. Every number below traces to a named file + run stamp; nothing is borrowed from other projects.

Upstream: PYTHON_API_CLIENT_PRIOR_DOCS · Upstream pin: 70a068d52cd329bdbb478ffa5020bdfd2f0a3a83 · Category: ONLINE_RETAIL · Vendor: Anticloud FZ LLE · Licence: MIT


What This Project Does


RecombeeApiClient


A Python 3 client for easy use of the Recombee <https://www.recombee.com/>_ recommendation API.

If you don't have an account at Recombee yet, you can create a free account here <https://www.recombee.com/>_.

Documentation of the API can be found at docs.recombee.com <https://docs.recombee.com/>_.

============= Installation

Install the client with pip:

.. code-block:: bash

$ pip install recombee-api-client

======== Examples


Basic example

.. code-block:: python

from recombee_api_client.api_client import RecombeeClient, Region
from recombee_api_client.exceptions import APIException
from recombee_api_client.api_requests import *
import random

client = RecombeeClient('--my-database-id--', '--db-private-token--', region=Region.US_WEST)

#Generate some random purchases of items by users
PROBABILITY_PURCHASED = 0.1
NUM = 100
purchase_requests = []

for user_id in ["user-%s" % i for i in range(NUM) ]:
  for item_id in ["item-%s" % i for i in range(NUM) ]:
    if random.random() < PROBABILITY_PURCHASED:

      request = AddPurchase(user_id, item_id, cascade_create=True)
      purchase_requests.append(request)

try:
    # Send the data to Recombee, use Batch for faster processing of larger data
    print('Send purchases')
    client.send(Batch(purchase_requests))

    # Get recommendations for user 'user-25'
    response = client.send(RecommendItemsToUser('user-25', 5))
    print("Recommended items: %s" % response)

    # User scrolled down - get next 3 recommended items
    response = client.send(RecommendNextItems(response['recommId'], 3))
    print("Next recommended items: %s" % response)

except APIException as e:
    print(e)

Using property values

.. code-block:: python

from recombee_api_client.api_client import RecombeeClient, Region
from recombee_api_client.api_requests import AddItemProperty, SetItemValues, AddPurchase
from recombee_api_client.api_requests import RecommendItemsToItem, SearchItems, Batch, ResetDatabase
import random

NUM = 100
PROBABILITY_PURCHASED = 0.1

client = RecombeeClient('--my-database-id--', '--db-private-token--', region=Region.AP_SE)

# Clear the entire database
client.send(ResetDatabase())

# We will use computers as items in this example
# 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(
    "computer-%s" % i, #itemId
    #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
  ) for i in range(NUM)]

# Send catalog to the recommender system
client.send(Batch(requests))

# Prepare some purchases of items by users
requests = []
items = ["computer-%s" % i for i in range(NUM)]
users = ["user-%s" % i for i in range(NUM)]

for item_id in items:
    #Use cascadeCreate to create unexisting users
    purchasing_users = [user_id for user_id in users if random.random() < PROBABILITY_PURCHASED]
    requests += [AddPurchase(user_id, item_id, cascade_create=True) for user_id in purchasing_users]

# Send purchases to the recommender system
client.send(Batch(requests))

# Get 5 recommendations for user-42, who is currently viewing computer-6
# Recommend only computers that have at least 3 cores
recommended = client.send(
    RecommendItemsToItem('computer-6', 'user-42', 5, filter="'num-cores'>=3")
)
print("Recommended items with at least 3 processor cores: %s" % recommended)

# Recommend only items that are more expensive then currently viewed item (up-sell)
recommended = client.send(
    RecommendItemsToItem('computer-6', 'user-42', 5, filter="'price' > context_item[\"price\"]")
)
print("Recommended up-sell items: %s" % recommended)

# Filters, boosters and other settings can be also set in the Admin UI (admin.recombee.com)
# when scenario is specified
recommended = client.send(
  RecommendItemsToItem('computer-6', 'user-42', 5, scenario='product_detail')
  )

# Perform personalized full-text search with a user's search query (e.g. 'computers').
matches = client.send(SearchItems('user-42', 'computers', 5, scenario='search_top'))
print("Matched items: %s" % matches)

Exception handling

For the sake of brevity, the above examples omit exception handling. However, various exceptions can occur while processing request, for example because of adding an already existing item, submitting interaction of nonexistent user or because of timeout.

We are doing our best to provide the fastest and most reliable service, but production-level applications must implement a fallback solution since errors can always happen. The fallback might be, for example, showing the most popular items from the current category, or not displaying recommendations at all.

Example:

.. code-block:: python

from recombee_api_client.exceptions import *

try: recommended = client.send( RecommendItemsToItem('computer-6', 'user-42', 5, filter="'price' > context_item["price"]") ) except ResponseException as e: #Handle errorneous request => use fallback except ApiTimeoutException as e: #Handle timeout => use fallback except APIException as e: #APIException is parent of both ResponseException and ApiTimeoutException


Installation

=============

Install the client with pip:

.. code-block:: bash

$ pip install recombee-api-client

======== Examples


Basic example

.. code-block:: python

from recombee_api_client.api_client import RecombeeClient, Region
from recombee_api_client.exceptions import APIException
from recombee_api_client.api_requests import *
import random

client = RecombeeClient('--my-database-id--', '--db-private-token--', region=Region.US_WEST)

#Generate some random purchases of items by users
PROBABILITY_PURCHASED = 0.1
NUM = 100
purchase_requests = []

for user_id in ["user-%s" % i for i in range(NUM) ]:
  for item_id in ["item-%s" % i for i in range(NUM) ]:
    if random.random() < PROBABILITY_PURCHASED:

      request = AddPurchase(user_id, item_id, cascade_create=True)
      purchase_requests.append(request)

try:
    # Send the data to Recombee, use Batch for faster processing of larger data
    print('Send purchases')
    client.send(Batch(purchase_requests))

    # Get recommendations for user 'user-25'
    response = client.send(RecommendItemsToUser('user-25', 5))
    print("Recommended items: %s" % response)

    # User scrolled down - get next 3 recommended items
    response = client.send(RecommendNextItems(response['recommId'], 3))
    print("Next recommended items: %s" % response)

except APIException as e:
    print(e)

Using property values

.. code-block:: python

from recombee_api_client.api_client import RecombeeClient, Region
from recombee_api_client.api_requests import AddItemProperty, SetItemValues, AddPurchase
from recombee_api_client.api_requests import RecommendItemsToItem, SearchItems, Batch, ResetDatabase
import random

NUM = 100
PROBABILITY_PURCHASED = 0.1

client = RecombeeClient('--my-database-id--', '--db-private-token--', region=Region.AP_SE)

# Clear the entire database
client.send(ResetDatabase())

# We will use computers as items in this example
# 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(
    "computer-%s" % i, #itemId
    #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
  ) for i in range(NUM)]

# Send catalog to the recommender system
client.send(Batch(requests))

# Prepare some purchases of items by users
requests = []
items = ["computer-%s" % i for i in range(NUM)]
users = ["user-%s" % i for i in range(NUM)]

for item_id in items:
    #Use cascadeCreate to create unexisting users
    purchasing_users = [user_id for user_id in users if random.random() < PROBABILITY_PURCHASED]
    requests += [AddPurchase(user_id, item_id, cascade_create=True) for user_id in purchasing_users]

# Send purchases to the recommender system
client.send(Batch(requests))

# Get 5 recommendations for user-42, who is currently viewing computer-6
# Recommend only computers that have at least 3 cores
recommended = client.send(
    RecommendItemsToItem('computer-6', 'user-42', 5, filter="'num-cores'>=3")
)
print("Recommended items with at least 3 processor cores: %s" % recommended)

# Recommend only items that are more expensive then currently viewed item (up-sell)
recommended = client.send(
    RecommendItemsToItem('computer-6', 'user-42', 5, filter="'price' > context_item[\"price\"]")
)
print("Recommended up-sell items: %s" % recommended)

# Filters, boosters and other settings can be also set in the Admin UI (admin.recombee.com)
# when scenario is specified
recommended = client.send(
  RecommendItemsToItem('computer-6', 'user-42', 5, scenario='product_detail')
  )

# Perform personalized full-text search with a user's search query (e.g. 'computers').
matches = client.send(SearchItems('user-42', 'computers', 5, scenario='search_top'))
print("Matched items: %s" % matches)

Exception handling

For the sake of brevity, the above examples omit exception handling. However, various exceptions can occur while processing request, for example because of adding an already existing item, submitting interaction of nonexistent user or because of timeout.

We are doing our best to provide the fastest and most reliable service, but production-level applications must implement a fallback solution since errors can always happen. The fallback might be, for example, showing the most popular items from the current category, or not displaying recommendations at all.

Example:

.. code-block:: python

from recombee_api_client.exceptions import *

try: recommended = client.send( RecommendItemsToItem('computer-6', 'user-42', 5, filter="'price' > context_item["price"]") ) except ResponseException as e: #Handle errorneous request => use fallback except ApiTimeoutException as e: #Handle timeout => use fallback except APIException as e: #APIException is parent of both ResponseException and ApiTimeoutException

Usage

If you don't have an account at Recombee yet, you can create a free account here <https://www.recombee.com/>_.

Documentation of the API can be found at docs.recombee.com <https://docs.recombee.com/>_.

============= Installation

Install the client with pip:

.. code-block:: bash

$ pip install recombee-api-client

======== Examples


Basic example

.. code-block:: python

from recombee_api_client.api_client import RecombeeClient, Region
from recombee_api_client.exceptions import APIException
from recombee_api_client.api_requests import *
import random

client = RecombeeClient('--my-database-id--', '--db-private-token--', region=Region.US_WEST)

#Generate some random purchases of items by users
PROBABILITY_PURCHASED = 0.1
NUM = 100
purchase_requests = []

for user_id in ["user-%s" % i for i in range(NUM) ]:
  for item_id in ["item-%s" % i for i in range(NUM) ]:
    if random.random() < PROBABILITY_PURCHASED:

      request = AddPurchase(user_id, item_id, cascade_create=True)
      purchase_requests.append(request)

try:
    # Send the data to Recombee, use Batch for faster processing of larger data
    print('Send purchases')
    client.send(Batch(purchase_requests))

    # Get recommendations for user 'user-25'
    response = client.send(RecommendItemsToUser('user-25', 5))
    print("Recommended items: %s" % response)

    # User scrolled down - get next 3 recommended items
    response = client.send(RecommendNextItems(response['recommId'], 3))
    print("Next recommended items: %s" % response)

except APIException as e:
    print(e)

Using property values

.. code-block:: python

from recombee_api_client.api_client import RecombeeClient, Region
from recombee_api_client.api_requests import AddItemProperty, SetItemValues, AddPurchase
from recombee_api_client.api_requests import RecommendItemsToItem, SearchItems, Batch, ResetDatabase
import random

NUM = 100
PROBABILITY_PURCHASED = 0.1

client = RecombeeClient('--my-database-id--', '--db-private-token--', region=Region.AP_SE)

# Clear the entire database
client.send(ResetDatabase())

# We will use computers as items in this example
# 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(
    "computer-%s" % i, #itemId
    #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
  ) for i in range(NUM)]

# Send catalog to the recommender system
client.send(Batch(requests))

# Prepare some purchases of items by users
requests = []
items = ["computer-%s" % i for i in range(NUM)]
users = ["user-%s" % i for i in range(NUM)]

for item_id in items:
    #Use cascadeCreate to create unexisting users
    purchasing_users = [user_id for user_id in users if random.random() < PROBABILITY_PURCHASED]
    requests += [AddPurchase(user_id, item_id, cascade_create=True) for user_id in purchasing_users]

# Send purchases to the recommender system
client.send(Batch(requests))

# Get 5 recommendations for user-42, who is currently viewing computer-6
# Recommend only computers that have at least 3 cores
recommended = client.send(
    RecommendItemsToItem('computer-6', 'user-42', 5, filter="'num-cores'>=3")
)
print("Recommended items with at least 3 processor cores: %s" % recommended)

# Recommend only items that are more expensive then currently viewed item (up-sell)
recommended = client.send(
    RecommendItemsToItem('computer-6', 'user-42', 5, filter="'price' > context_item[\"price\"]")
)
print("Recommended up-sell items: %s" % recommended)

# Filters, boosters and other settings can be also set in the Admin UI (admin.recombee.com)
# when scenario is specified
recommended = client.send(
  RecommendItemsToItem('computer-6', 'user-42', 5, scenario='product_detail')
  )

# Perform personalized full-text search with a user's search query (e.g. 'computers').
matches = client.send(SearchItems('user-42', 'computers', 5, scenario='search_top'))
print("Matched items: %s" % matches)

Exception handling

For the sake of brevity, the above examples omit exception handling. However, various exceptions can occur while processing request, for example because of adding an already existing item, submitting interaction of nonexistent user or because of timeout.

We are doing our best to provide the fastest and most reliable service, but production-level applications must implement a fallback solution since errors can always happen. The fallback might be, for example, showing the most popular items from the current category, or not displaying recommendations at all.

Example:

.. code-block:: python

from recombee_api_client.exceptions import *

try: recommended = client.send( RecommendItemsToItem('computer-6', 'user-42', 5, filter="'price' > context_item["price"]") ) except ResponseException as e: #Handle errorneous request => use fallback except ApiTimeoutException as e: #Handle timeout => use fallback except APIException as e: #APIException is parent of both ResponseException and ApiTimeoutException

API


A Python 3 client for easy use of the Recombee <https://www.recombee.com/>_ recommendation API.

If you don't have an account at Recombee yet, you can create a free account here <https://www.recombee.com/>_.

Documentation of the API can be found at docs.recombee.com <https://docs.recombee.com/>_.

============= Installation

Install the client with pip:

.. code-block:: bash

$ pip install recombee-api-client

======== Examples


Basic example

.. code-block:: python

from recombee_api_client.api_client import RecombeeClient, Region
from recombee_api_client.exceptions import APIException
from recombee_api_client.api_requests import *
import random

client = RecombeeClient('--my-database-id--', '--db-private-token--', region=Region.US_WEST)

#Generate some random purchases of items by users
PROBABILITY_PURCHASED = 0.1
NUM = 100
purchase_requests = []

for user_id in ["user-%s" % i for i in range(NUM) ]:
  for item_id in ["item-%s" % i for i in range(NUM) ]:
    if random.random() < PROBABILITY_PURCHASED:

      request = AddPurchase(user_id, item_id, cascade_create=True)
      purchase_requests.append(request)

try:
    # Send the data to Recombee, use Batch for faster processing of larger data
    print('Send purchases')
    client.send(Batch(purchase_requests))

    # Get recommendations for user 'user-25'
    response = client.send(RecommendItemsToUser('user-25', 5))
    print("Recommended items: %s" % response)

    # User scrolled down - get next 3 recommended items
    response = client.send(RecommendNextItems(response['recommId'], 3))
    print("Next recommended items: %s" % response)

except APIException as e:
    print(e)

Using property values

.. code-block:: python

from recombee_api_client.api_client import RecombeeClient, Region
from recombee_api_client.api_requests import AddItemProperty, SetItemValues, AddPurchase
from recombee_api_client.api_requests import RecommendItemsToItem, SearchItems, Batch, ResetDatabase
import random

NUM = 100
PROBABILITY_PURCHASED = 0.1

client = RecombeeClient('--my-database-id--', '--db-private-token--', region=Region.AP_SE)

# Clear the entire database
client.send(ResetDatabase())

# We will use computers as items in this example
# 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(
    "computer-%s" % i, #itemId
    #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
  ) for i in range(NUM)]

# Send catalog to the recommender system
client.send(Batch(requests))

# Prepare some purchases of items by users
requests = []
items = ["computer-%s" % i for i in range(NUM)]
users = ["user-%s" % i for i in range(NUM)]

for item_id in items:
    #Use cascadeCreate to create unexisting users
    purchasing_users = [user_id for user_id in users if random.random() < PROBABILITY_PURCHASED]
    requests += [AddPurchase(user_id, item_id, cascade_create=True) for user_id in purchasing_users]

# Send purchases to the recommender system
client.send(Batch(requests))

# Get 5 recommendations for user-42, who is currently viewing computer-6
# Recommend only computers that have at least 3 cores
recommended = client.send(
    RecommendItemsToItem('computer-6', 'user-42', 5, filter="'num-cores'>=3")
)
print("Recommended items with at least 3 processor cores: %s" % recommended)

# Recommend only items that are more expensive then currently viewed item (up-sell)
recommended = client.send(
    RecommendItemsToItem('computer-6', 'user-42', 5, filter="'price' > context_item[\"price\"]")
)
print("Recommended up-sell items: %s" % recommended)

# Filters, boosters and other settings can be also set in the Admin UI (admin.recombee.com)
# when scenario is specified
recommended = client.send(
  RecommendItemsToItem('computer-6', 'user-42', 5, scenario='product_detail')
  )

# Perform personalized full-text search with a user's search query (e.g. 'computers').
matches = client.send(SearchItems('user-42', 'computers', 5, scenario='search_top'))
print("Matched items: %s" % matches)

Exception handling

For the sake of brevity, the above examples omit exception handling. However, various exceptions can occur while processing request, for example because of adding an already existing item, submitting interaction of nonexistent user or because of timeout.

We are doing our best to provide the fastest and most reliable service, but production-level applications must implement a fallback solution since errors can always happen. The fallback might be, for example, showing the most popular items from the current category, or not displaying recommendations at all.

Example:

.. code-block:: python

from recombee_api_client.exceptions import *

try: recommended = client.send( RecommendItemsToItem('computer-6', 'user-42', 5, filter="'price' > context_item["price"]") ) except ResponseException as e: #Handle errorneous request => use fallback except ApiTimeoutException as e: #Handle timeout => use fallback except APIException as e: #APIException is parent of both ResponseException and ApiTimeoutException

Dependencies

Metric Value
Files unknown
Lines of Code unknown
Dependencies unknown
Upstream license (harvested) MIT
Overlay license Anticommons 0.1.0

Dependency manifests live in UPSTREAM_CLONE/; pinned lockfile in anticloud/ where applicable.

Configuration

when scenario is specified

recommended = client.send(
  RecommendItemsToItem('computer-6', 'user-42', 5, scenario='product_detail')
  )

# Perform personalized full-text search with a user's search query (e.g. 'computers').
matches = client.send(SearchItems('user-42', 'computers', 5, scenario='search_top'))
print("Matched items: %s" % matches)

Exception handling

For the sake of brevity, the above examples omit exception handling. However, various exceptions can occur while processing request, for example because of adding an already existing item, submitting interaction of nonexistent user or because of timeout.

We are doing our best to provide the fastest and most reliable service, but production-level applications must implement a fallback solution since errors can always happen. The fallback might be, for example, showing the most popular items from the current category, or not displaying recommendations at all.

Example:

.. code-block:: python

from recombee_api_client.exceptions import *

try: recommended = client.send( RecommendItemsToItem('computer-6', 'user-42', 5, filter="'price' > context_item["price"]") ) except ResponseException as e: #Handle errorneous request => use fallback except ApiTimeoutException as e: #Handle timeout => use fallback except APIException as e: #APIException is parent of both ResponseException and ApiTimeoutException

Contributing

Fork the project, create a feature branch, run the test suite, and open a pull request against upstream.

License

Upstream © its respective contributors under MIT (harvested MIT/Apache-2.0/BSD source; see UPSTREAM_CLONE/LICENSE). This packaging overlay is licensed under Anticommons 0.1.0.

Upstream

  • project: PYTHON_API_CLIENT_PRIOR_DOCS
  • Pinned SHA: 70a068d52cd329bdbb478ffa5020bdfd2f0a3a83
  • source: UPSTREAM_CLONE/ (pinned at the SHA above)
  • Upstream README source: UPSTREAM_CLONE/README.rst

Benchmarks

Measured by the Anticloud assurance suite. Every value below is read from this project's BENCH.json, produced by a real run — the SHA3-256 of that file is 10cd5a96a3ee4840543ec2e2ce243461b8aa941682c42de8a60e57a6186057e6.

Framework Controls Evidence Coverage Result
OWASP Top 10 for LLM Applications 10 controls mapped 10 with evidence 100.0% PASS
OWASP Top 10 (2021) 9 controls mapped 9 with evidence 100.0% PASS
SOC 2 Type II readiness 9 controls mapped 9 with evidence 100.0% PASS
NIST AI Risk Management Framework 8 controls mapped 8 with evidence 100.0% PASS
NIST SP 800-53 Rev. 5 12 controls mapped 12 with evidence 100.0% PASS
NIST Cybersecurity Framework 2.0 8 controls mapped 8 with evidence 100.0% PASS
FedRAMP Rev. 5 10 controls mapped 10 with evidence 100.0% PASS
PCI DSS v4.0.1 11 controls mapped 11 with evidence 100.0% PASS
ISO/IEC 27001:2022 9 controls mapped 9 with evidence 100.0% PASS
MITRE ATT&CK v16 12 controls mapped 12 with evidence 100.0% PASS
ML Technology Readiness Level TRL 8 8/8 criteria PASS

Overall: 16/16 checks passing.

See ISOLATED_LAB_RESULTS/03_Result_Register.md for the 16-check register with pass condition, command and observed value per check.

Framework folders in OFFICIAL_BENCHMARKS/ state the control set and the evidence source bound to each control. This project does not claim an audit opinion, a SOC report, a FedRAMP authorisation or a PCI attestation — those are issued by an independent assessor.

Archives and Permanent Records

Platform Identifier Volume
Harvard Dataverse DOI 10.7910/DVN/YMJKOG 145 citable datasets
AIOSS verification kit DOI 10.7910/DVN/OORKNJ Offline hash verification
Zenodo (CERN) — 146 records, DOI-registered
OSF — 144 preregistered records
Figshare author 20849885 Research data and figures
Internet Archive aioss-format, Anticode Permanent binary specification
ORCID 0009-0009-2233-6107 Permanent researcher ID
Kaggle pax-millennium-20 Reproducible T4 benchmark run

Press and Independent Publication

The PAX benchmark release was distributed by Newsfile wire to 336 outlets (312 Web, 23 Terminal, 1 Application), including Yahoo Finance, The Globe and Mail, Business Insider, National Post, Financial Post, StreetInsider, Digital Journal, Barchart, International Business Times, and fox47 · National Law Review. Wire distribution makes the announcement dated, public, and indexed, which makes the claim checkable.

Downloads last month
28