Hamming-LUCB
The hlucb package is a Python implementation of the paper Approximate ranking from pairwise comparisons.
Heckel, R., Simchowitz, M., Ramchandran, K., & Wainwright, M. (2018, March). Approximate ranking from pairwise comparisons. In International Conference on Artificial Intelligence and Statistics (pp. 1057-1066). PMLR.
Installation
hlucb is installable with pip:
$ pip install hlucb
Usage
Ranking with a comparator
from hlucb import HammingLUCB
items = [4, 1, 2, 6, 5, 8, 9, 3]
k = 5
h = 2
delta = 0.9
def compare(item_a: int, item_b: int) -> bool:
return item_a > item_b
scores, bounds = HammingLUCB.from_comparator(items, k, h, delta, compare, seed=42)
print("Scores: ", scores)
print("Bounds: ", bounds)
Ranking with a generator
from hlucb import HammingLUCB
items = [4, 1, 2, 6, 5, 8, 9, 3]
n = len(items)
k = 5
h = 2
delta = 0.9
generator = HammingLUCB.get_generator(n, k, h, delta, seed=42)
scores = None
bounds = None
for (i, j), (scores, bounds) in generator:
comparison = items[i] > items[j]
generator.send(comparison)
print("Scores: ", scores)
print("Bounds: ", bounds)
Intuition
The Hamming-LUCB algorithm approximately ranks $n$ items, estimates the score of each item, and provides confidence bounds for each score. The intuition behind the approximate ranking is that it's easier to compare items with very different scores, so it should be possible to separate high-scoring items from low-scoring items with few comparisons and high confidence even if the exact ranking is not discovered.
The sets of high- and low-scoring items are designated $S_1$ and $S_2$ respectively. Hamming-LUCB extracts $S_1$ and $S_2$ such that all items in $S_1$ are expected to have higher scores than all items in $S_2$.
Parameters:
- $n$ - the total number of items
- $k$ - the number of items to extract as high-scoring items
- $h$ - half the margin between $S_1$ and $S_2$
- $\delta$ - confidence parameter for the probability of achieving $h$-Hamming accuracy
Definitions:
- The Hamming distance between two sets: $D_H(S_1, S_2) = \lvert (S_1 \cup S_2) \setminus (S_1 \cap S_2) \rvert$
- A ranking $\hat{S_1}$, $\hat{S_2}$ is $h$-Hamming accurate if: $D_H(\hat{S_l}, S_l) \leq 2h$ for
- $\lvert \hat{S_l} \rvert = \lvert S_l \rvert$
- $l \in {1, 2}$
- A ranking algorithm is $(h, \delta)$-accurate if the ranking returned is $h$-Hamming accurate with probability at least $1 - \delta$.
Metadata
Release files for hlucb 0.1.4
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 |
|---|---|---|---|---|
| hlucb-0.1.4.tar.gz | 5.5 kB | Without provenance | Details for hlucb-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hlucb-0.1.4-py3-none-any.whl | Python 3 | none | any | Details for hlucb-0.1.4-py3-none-any.whl |
Total release size: 10.8 kB
Release files / hlucb-0.1.4.tar.gz
| Download URL | hlucb-0.1.4.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8fda69eb9400c6d6579a33b32dbab2e9d88ef0e6d9a4ac964d4490d27591ae0e
|
|
BLAKE2b-256 checksum How to use checksums |
3e822e27f674cc502762ee17f6abae945acf61a60daf4c1f1301d9dc15c51bf7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.1 CPython/3.9.12 Darwin/22.2.0
|
Release files / hlucb-0.1.4-py3-none-any.whl
| Download URL | hlucb-0.1.4-py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a2eb614b652eb772aacc77d562f97818e645533c1e949ed68e17cdf6bc268320
|
|
BLAKE2b-256 checksum How to use checksums |
7e2125419bbb083d22d4ee4189ac9de31c9f21af73025804301b559934e76953
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.1 CPython/3.9.12 Darwin/22.2.0
|
Security for hlucb 0.1.4
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.