mab-ranking
A library for Online Ranking with Multi-Armed-Bandits. This library is useful to find the best Top N items among a relatively small candidate set.
For example:
- Show the Top 5 News Articles among 200 articles every day
- Recommend the Top 10 Trending Products every week
- Rank components on websites to drive more engagement (Whole Page Optimization)
Installation
Prerequisites
mab-ranking requires the following:
- Python (3.6, 3.7, 3.8)
Install mab-ranking
At the command line:
pip install mab-ranking
Getting started
Let's say that you want to recommend the top 5 trending products to your website visitors every week among the 300 most selling products. Every Monday at some time T you'll define a new RankBandit implementation. For example:
num_ranks = 5
num_arms = 300
rank_bandit = IndependentBandits(num_ranks, BetaThompsonSampling, num_arms=num_arms)
Then, every time a visitor X is landed on your home page for the rest of the week, you need to select which 5 products to show them in section Top Trending Products. So, you'll do the following:
selected_arms = rank_bandit.choose()
Let's say that the selected_arms equals [30, 2, 200, 42]. That means that you need to show products, 30, 2, 200 and 42 in this order. You can keep your own mapping from product UUIDS to integer arm ids in your app's business logic.
The visitor X viewed this selected order. Let's say that (s)he clicked on products 2 and 42. Then the rewards list will be [0.0, 1.0, 0.0, 1.0]. So:
rewards = [0.0, 1.0, 0.0, 1.0]
rank_bandit.choose(selected_arms, rewards)
Implementation Details
Implementations of RankBandit:
IndependentBandits: from Microsoft Paper, "A Fast Bandit Algorithm for Recommendations to Users with Heterogeneous"
Implementations of Bandit:
BetaThompsonSampling: Beta Thompson Sampling MAB
Metadata
Release files for mab-ranking 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mab-ranking-0.0.1.tar.gz | 4.6 kB | Without provenance | Details for mab-ranking-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mab_ranking-0.0.1-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for mab_ranking-0.0.1-py2.py3-none-any.whl |
Total release size: 11.8 kB
Release files / mab-ranking-0.0.1.tar.gz
| Download URL | mab-ranking-0.0.1.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cc2816306c28624f0be77cc9a99d685f376ea602134160d733c164721ad0baa6
|
|
BLAKE2b-256 checksum How to use checksums |
368ddb95733eb2654a2692226ba40cfaed07c66e4463952464ed0acca95ed587
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.20.1 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.6
|
Release files / mab_ranking-0.0.1-py2.py3-none-any.whl
| Download URL | mab_ranking-0.0.1-py2.py3-none-any.whl |
|---|---|
| Size | 7.1 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
65911758f10b6e58956fafeb226b0c9c32fcf91648ea468ddd516945006c7e9e
|
|
BLAKE2b-256 checksum How to use checksums |
b691d73c7f14b74d5fb8b3196e8ba75a8e7aa0fbbcec977ab60095edcf7aaef0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.20.1 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.6
|
Security for mab-ranking 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.