Python SDK for gorse recommender system
Project description
PyGorse
Python SDK for gorse recommender system.
Install
- Install from PyPI:
pip install PyGorse
- Install from source:
git clone https://github.com/gorse-io/PyGorse.git
cd PyGorse
pip install .
Usage
Create a client by the entrypoint and api key.
from gorse import Gorse
client = Gorse('http://127.0.0.1:8087', 'api_key')
# Insert a user
client.insert_user({
'UserId': 'bob',
'Labels': {
'gender': 'M',
'age': 24
},
'Comment': 'my user'
})
# Insert items
client.insert_item({
'ItemId': 'vuejs:vue',
'IsHidden': False,
'Labels': {
'language': 'JavaScript'
},
'Categories': ['framework'],
'Timestamp': '2022-02-24T00:00:00Z',
'Comment': 'Vue.js framework'
})
# Insert feedbacks
client.insert_feedbacks([
{ 'FeedbackType': 'star', 'UserId': 'bob', 'ItemId': 'vuejs:vue', 'Timestamp': '2022-02-24T00:00:00Z' },
{ 'FeedbackType': 'star', 'UserId': 'bob', 'ItemId': 'd3:d3', 'Timestamp': '2022-02-25T00:00:00Z' },
{ 'FeedbackType': 'star', 'UserId': 'bob', 'ItemId': 'dogfalo:materialize', 'Timestamp': '2022-02-26T00:00:00Z' },
{ 'FeedbackType': 'star', 'UserId': 'bob', 'ItemId': 'mozilla:pdf.js', 'Timestamp': '2022-02-27T00:00:00Z' },
{ 'FeedbackType': 'star', 'UserId': 'bob', 'ItemId': 'moment:moment', 'Timestamp': '2022-02-28T00:00:00Z' }
])
# Get recommendation
client.get_recommend('bob', n=10)
The Python SDK implements the async client as well:
from gorse import AsyncGorse
client = AsyncGorse('http://127.0.0.1:8087', 'api_key')
# Insert a user
await client.insert_user({
'UserId': 'bob',
'Labels': {
'gender': 'M',
'age': 24
},
'Comment': 'my user'
})
# Insert items
await client.insert_item({
'ItemId': 'vuejs:vue',
'IsHidden': False,
'Labels': {
'language': 'JavaScript'
},
'Categories': ['framework'],
'Timestamp': '2022-02-24T00:00:00Z',
'Comment': 'Vue.js framework'
})
# Insert feedbacks
await client.insert_feedbacks([
{ 'FeedbackType': 'star', 'UserId': 'bob', 'ItemId': 'vuejs:vue', 'Timestamp': '2022-02-24T00:00:00Z' },
{ 'FeedbackType': 'star', 'UserId': 'bob', 'ItemId': 'd3:d3', 'Timestamp': '2022-02-25T00:00:00Z' },
{ 'FeedbackType': 'star', 'UserId': 'bob', 'ItemId': 'dogfalo:materialize', 'Timestamp': '2022-02-26T00:00:00Z' },
{ 'FeedbackType': 'star', 'UserId': 'bob', 'ItemId': 'mozilla:pdf.js', 'Timestamp': '2022-02-27T00:00:00Z' },
{ 'FeedbackType': 'star', 'UserId': 'bob', 'ItemId': 'moment:moment', 'Timestamp': '2022-02-28T00:00:00Z' }
])
# Get recommendation
await client.get_recommend('bob', n=10)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pygorse-0.5.1.tar.gz
(9.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pygorse-0.5.1.tar.gz.
File metadata
- Download URL: pygorse-0.5.1.tar.gz
- Upload date:
- Size: 9.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6dbeb242fba8cbbc89c4de425fa619933830f4ba4dbba18e82dbc3c059cbbce3
|
|
| MD5 |
870705cc4eb1e64e93440ca4cf9bab84
|
|
| BLAKE2b-256 |
f618d33b977b74657dd709f6ce3385b6c4c1d809a59f4a18386c39c3cb3888bd
|
File details
Details for the file pygorse-0.5.1-py3-none-any.whl.
File metadata
- Download URL: pygorse-0.5.1-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f28709a9d959dc28f54b7149dfeb619c4c912fd8972be72d2dfb3502411c106
|
|
| MD5 |
43f207dbef8484c1314dd999617b5591
|
|
| BLAKE2b-256 |
2cdd84d50653d7111f269c1b3c817d689fd36da92d15ccb14e736125755f202f
|