Skip to content
Back to skills

Weightedtau

ASecurity

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

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

Security analysis

A100/100

Scanned September 11, 2026

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

Installs into .claude/skills of the current project.

Are you the author of Weightedtau?

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

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

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: weightedtau
description: Compute the weightedtau metric — provided by scipy.stats. Use when the user has predictions and ground-truth and needs to compute weightedtau, or asks how to score with weightedtau.
metadata:
  skill_kind: metric
  source_lib: scipy.stats
  import_path: scipy.stats.weightedtau
  source: library_introspection
---

# weightedtau

> Metric `weightedtau` from `scipy.stats` (scipy.stats.weightedtau)

## When to invoke this skill

The user has predictions + ground truth and asks to evaluate with weightedtau, or
mentions `scipy.stats.weightedtau` directly, or wants the standard scipy.stats implementation.

## Reference signature

```python
from scipy.stats import weightedtau

# weightedtau(x, y, rank=True, weigher=None, additive=True, *, axis=None, nan_policy='propagate', keepdims=False)
```

## Library docstring

```
Compute a weighted version of Kendall's :math:`\tau`.

The weighted :math:`\tau` is a weighted version of Kendall's
:math:`\tau` in which exchanges of high weight are more influential than
exchanges of low weight. The default parameters compute the additive
hyperbolic version of the index, :math:`\tau_\mathrm h`, which has
been shown to provide the best balance between important and
unimportant elements [1]_.

The weighting is defined by means of a rank array, which assigns a
nonnegative rank to each element (higher importance ranks being
associated with smaller values, e.g., 0 is the highest possible rank),
and a weigher function, which assigns a weight based on the rank to
each element. The weight of an exchange is then the sum or the product
of the weights of the ranks of the exchanged elements. The default
parameters compute :math:`\tau_\mathrm h`: an exchange between
elements with rank :math:`r` and :math:`s` (starting from zero) has
weight :math:`1/(r+1) + 1/(s+1)`.

Specifying a rank array is meaningful only if you have in mind an
external criterion of importance. If, as it usually happens, you do
not have in mind a specific rank, the weighted :math:`\tau` is
defined by averaging the values obtained using the decreasing
lexicographical rank by (`x`, `y`) and by (`y`, `x`). This is the
behavior with default parameters. Note that the convention used
here for ranking (lower values imply higher importance) is opposite
to that used by other SciPy statistical functions.

Parameters
----------
x, y : array_like
    Arrays of scores, of the same shape. If arrays are not 1-D, they will
    be flattened to 1-D.
rank : array_like of ints or bool, optional
    A nonnegative rank assigned to each element. If it is None, the
    decreasing lexicographical rank by (`x`, `y`) will be used: elements of
    higher rank will be those with larger `x`-values, using `y`-values to
    break ties (in particular, swapping `x` and `y` will give a different
    result). If it is False, the element indices will be used
    directly as ranks. The default is True, in which case this
    function returns the average of the values obtained using the
    decreasing lexicographical rank b
```

## Quick recipe

```python
import scipy.stats as _m
score = _m.weightedtau(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.