Metadata-Version: 2.5
Name: ranked-overlap
Version: 0.1.0
Summary: Compare ranked lists with Rank-Biased Overlap
Project-URL: Homepage, https://github.com/enKRypted15/ranked-overlap
Project-URL: Repository, https://github.com/enKRypted15/ranked-overlap
Project-URL: Issues, https://github.com/enKRypted15/ranked-overlap/issues
Project-URL: Article, https://medium.com/data-science/how-to-objectively-compare-two-ranked-lists-in-python-b3d74e236f6a
Author: Krupesh Raikar
License-Expression: MIT
License-File: LICENSE
Keywords: information-retrieval,rank-biased-overlap,ranking,rbo,similarity
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Classifier: Typing :: Typed
Requires-Python: >=3.9
Provides-Extra: dev
Requires-Dist: build>=1.2; extra == 'dev'
Requires-Dist: mypy>=1.11; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Requires-Dist: twine>=5.1; extra == 'dev'
Description-Content-Type: text/markdown

# ranked-overlap

`ranked-overlap` compares ordered lists using Rank-Biased Overlap (RBO). It is a
production-ready version of the implementation introduced in my
[Towards Data Science article](https://medium.com/data-science/how-to-objectively-compare-two-ranked-lists-in-python-b3d74e236f6a).

RBO is useful when rankings may have different lengths or contain different
items, and when agreement near the top matters more than agreement near the
bottom. Scores range from `0` (disjoint) to `1` (identical).

## Installation

```bash
pip install ranked-overlap
```

## Python API

```python
from ranked_overlap import cumulative_weight, rbo

first = [1, 2, 3, 4, 5, 6, 7]
second = [1, 3, 2, 4, 5, 7, 6, 8]

score = rbo(first, second)
print(score)  # 0.8853713875

print(cumulative_weight(p=0.9, depth=10))  # 0.8555854467...
```

The persistence parameter `p` must lie strictly between `0` and `1`. Lower
values concentrate more weight at the beginning of each ranking. Rankings may
be any iterable, but their items must be unique and hashable.

For compatibility with the original article, `weightage_calculator(p, d)` is
available as an alias for `cumulative_weight(p, depth)`.

## Command line

```bash
ranked-overlap compare '["a", "b", "c"]' '["a", "c", "b"]' --p 0.9
ranked-overlap weight 10 --p 0.9
```

## Development

```bash
python -m pip install -e '.[dev]'
ruff check .
mypy
pytest
python -m build
twine check dist/*
```

## Citation

RBO was introduced by William Webber, Alistair Moffat, and Justin Zobel in
“A Similarity Measure for Indefinite Rankings,” *ACM Transactions on
Information Systems*, 2010. See `CITATION.cff` for citation metadata.

## License

MIT © Krupesh Raikar

