Skip to content
Back to skills

Multilabelrankingaverageprecision

ASecurity

Compute the MultilabelRankingAveragePrecision metric — provided by torchmetrics. Use when the user has predictions and ground-truth and needs to compute MultilabelRankingAveragePrecision, or asks how to score with MultilabelRankingAveragePrecision.

  • 3 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 11, 2026
documentationpythongit

Security analysis

A100/100

Scanned September 11, 2026

npx -y skills add qhjqhj00/research-skills-pool --skill multilabelrankingaverageprecision --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Multilabelrankingaverageprecision?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Multilabelrankingaverageprecision
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/qhjqhj00-multilabelrankingaverageprecision/badge)](https://www.skillsdirectory.com/skills/qhjqhj00-multilabelrankingaverageprecision)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: multilabelrankingaverageprecision
description: Compute the MultilabelRankingAveragePrecision metric — provided by torchmetrics. Use when the user has predictions and ground-truth and needs to compute MultilabelRankingAveragePrecision, or asks how to score with MultilabelRankingAveragePrecision.
metadata:
  skill_kind: metric
  source_lib: torchmetrics
  import_path: torchmetrics.classification.MultilabelRankingAveragePrecision
  source: library_introspection
---

# multilabelrankingaverageprecision

> Metric `MultilabelRankingAveragePrecision` from `torchmetrics` (torchmetrics.classification.MultilabelRankingAveragePrecision)

## When to invoke this skill

The user has predictions + ground truth and asks to evaluate with MultilabelRankingAveragePrecision, or
mentions `torchmetrics.classification.MultilabelRankingAveragePrecision` directly, or wants the standard torchmetrics implementation.

## Reference signature

```python
from torchmetrics.classification import MultilabelRankingAveragePrecision

# MultilabelRankingAveragePrecision(num_labels: int, ignore_index: Optional[int] = None, validate_args: bool = True, **kwargs: Any) -> None
```

## Library docstring

```
Compute label ranking average precision score for multilabel data [1].

The score is the average over each ground truth label assigned to each sample of the ratio of true vs. total labels
with lower score. Best score is 1.

As input to ``forward`` and ``update`` the metric accepts the following input:

- ``preds`` (:class:`~torch.Tensor`): A float tensor of shape ``(N, C, ...)``. Preds should be a tensor
  containing probabilities or logits for each observation. If preds has values outside [0,1] range we consider
  the input to be logits and will auto apply sigmoid per element.
- ``target`` (:class:`~torch.Tensor`): An int tensor of shape ``(N, C, ...)``. Target should be a tensor
  containing ground truth labels, and therefore only contain {0,1} values (except if `ignore_index` is specified).

.. tip::
   Additional dimension ``...`` will be flattened into the batch dimension.

As output to ``forward`` and ``compute`` the metric returns the following output:

- ``mlrap`` (:class:`~torch.Tensor`): A tensor containing the multilabel ranking average precision.

Args:
    num_labels: Integer specifying the number of labels
    ignore_index:
        Specifies a target value that is ignored and does not contribute to the metric calculation
    validate_args: bool indicating if input arguments and tensors should be validated for correctness.
        Set to ``False`` for faster computations.

Example:
    >>> from torch import rand, randint
    >>> from torchmetrics.classification import MultilabelRankingAveragePrecision
    >>> preds = rand(10, 5)
    >>> target = randint(2, (10, 5))
    >>> mlrap = MultilabelRankingAveragePrecision(num_labels=5)
    >>> mlrap(preds, target)
    tensor(0.7744)
```

## Quick recipe

```python
import torchmetrics.classification as _m
score = _m.MultilabelRankingAveragePrecision(y_true, y_pred)
```

## Don'ts

- Don't reimplement when the library version handles edge cases (NaN, ties, empty inputs) better than a hand-rolled formula.
- Always check the library version's argument order — sklearn is `(y_true, y_pred)` while torchmetrics is `(preds, target)`.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.