Registry / ai-ml / ranx
library0.3.21pypypi✓ verified 86d ago

ranx is a blazing-fast Python library for ranking evaluation, comparison, and fusion. Version 0.3.21 supports Python >=3.8. It provides efficient computation of IR metrics (MAP, NDCG, etc.), statistical significance tests, and result fusion. Release cadence is irregular.

pip install ranx
INSTALL
IMPORT
SIG · RANX
R
ranx
ai-mlpythonv0.3.21
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

compare
from ranx import compare
correct import
fuse
from ranx import fuse
correct import
evaluate
from ranx import evaluate
correct import

Create Qrels and Runs, evaluate metrics, compare runs with statistical tests, and fuse runs.

from ranx import evaluate, compare, fuse from ranx import Run, Qrels # Create Qrels and Run objects from dicts qrels_dict = {"q1": {"d1": 1, "d2": 0}, "q2": {"d3": 1}} run_dict = {"q1": {"d1": 0.9, "d2": 0.8}, "q2": {"d3": 0.95}} qrels = Qrels(qrels_dict) run = Run(run_dict) # Evaluate single run results = evaluate(qrels, run, "ndcg@5,map@5") print(results) # Compare two runs run2_dict = {"q1": {"d1": 0.85, "d2": 0.75}, "q2": {"d3": 0.9}} run2 = Run(run2_dict) report = compare(qrels, [run, run2], metrics=["ndcg@5", "map@5"]) print(report) # Fuse runs combined = fuse([run, run2], method="rbc") print(combined)
Debug
Known issues
breakingIn ranx 0.2.x, the API used `Qrels` and `Run` from `ranx` but some functions expected pandas DataFrames. In 0.3.x, all inputs are dict-based or custom objects. Old code using DataFrame directly may break.
fix
Convert DataFrames to dicts or use `Qrels.from_df()` and `Run.from_df()` methods.
affects: <0.3.0
gotchaMetrics string must not contain spaces. e.g., 'ndcg@5, map@5' will cause a parsing error. Use 'ndcg@5,map@5'.
fix
Remove spaces: 'ndcg@5,map@5'
affects: All
gotcharanx uses 0-based relevance scores internally, but Qrels values should be non-negative integers. Using floats may cause unexpected behavior.
fix
Ensure relevance scores are integers (0, 1, 2, ...).
affects: All
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'ranx'
ranx not installed or installed in a different environment.
fix
Run `pip install ranx` in your current Python environment.
KeyError: 'qrels'
Passing a dict directly to evaluate() without wrapping in Qrels.
fix
Wrap qrels dict in `Qrels(qrels_dict)` before passing to evaluate.
Upgrade
Version history
0.3.21latest on PyPI · released Aug 7, 2025
Audit
Dependencies
numpyrequiredNumerical computations and array operations.
scipyrequiredStatistical tests (e.g., t-test, Wilcoxon).
pandasoptionalData handling for results and runs.
Agent activity
39 hits · last 30 days
node
36
Resources
ranx — pip install ranx · libregistry