Skip to content
Back to skills

Label Ranking Loss

ASecurity

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

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

Security analysis

A100/100

Scanned September 11, 2026

npx -y skills add qhjqhj00/research-skills-pool --skill label-ranking-loss --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Label Ranking Loss?

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

Security grade badge for Label Ranking Loss
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/qhjqhj00-label-ranking-loss/badge)](https://www.skillsdirectory.com/skills/qhjqhj00-label-ranking-loss)

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: label-ranking-loss
description: Compute the label_ranking_loss metric — provided by scikit-learn. Use when the user has predictions and ground-truth and needs to compute label_ranking_loss, or asks how to score with label_ranking_loss.
metadata:
  skill_kind: metric
  source_lib: scikit-learn
  import_path: sklearn.metrics.label_ranking_loss
  source: library_introspection
---

# label-ranking-loss

> Metric `label_ranking_loss` from `scikit-learn` (sklearn.metrics.label_ranking_loss)

## When to invoke this skill

The user has predictions + ground truth and asks to evaluate with label_ranking_loss, or
mentions `sklearn.metrics.label_ranking_loss` directly, or wants the standard scikit-learn implementation.

## Reference signature

```python
from sklearn.metrics import label_ranking_loss

# label_ranking_loss(y_true, y_score, *, sample_weight=None)
```

## Library docstring

```
Compute Ranking loss measure.

Compute the average number of label pairs that are incorrectly ordered
given y_score weighted by the size of the label set and the number of
labels not in the label set.

This is similar to the error set size, but weighted by the number of
relevant and irrelevant labels. The best performance is achieved with
a ranking loss of zero.

Read more in the :ref:`User Guide <label_ranking_loss>`.

.. versionadded:: 0.17
   A function *label_ranking_loss*

Parameters
----------
y_true : {array-like, sparse matrix} of shape (n_samples, n_labels)
    True binary labels in binary indicator format.

y_score : array-like of shape (n_samples, n_labels)
    Target scores, can either be probability estimates of the positive
    class, confidence values, or non-thresholded measure of decisions
    (as returned by "decision_function" on some classifiers).
    For :term:`decision_function` scores, values greater than or equal to
    zero should indicate the positive class.

sample_weight : array-like of shape (n_samples,), default=None
    Sample weights.

Returns
-------
loss : float
    Average number of label pairs that are incorrectly ordered given
    y_score weighted by the size of the label set and the number of labels not
    in the label set.

References
----------
.. [1] Tsoumakas, G., Katakis, I., & Vlahavas, I. (2010).
       Mining multi-label data. In Data mining and knowledge discovery
       handbook (pp. 667-685). Springer US.

Examples
--------
>>> from sklearn.metrics import label_ranking_loss
>>> y_true = [[1, 0, 0], [0, 0, 1]]
>>> y_score = [[0.75, 0.5, 1], [1, 0.2, 0.1]]
>>> label_ranking_loss(y_true, y_score)
0.75
```

## Quick recipe

```python
import sklearn.metrics as _m
score = _m.label_ranking_loss(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.