Compute the kendalltau metric — provided by scipy.stats. Use when the user has predictions and ground-truth and needs to compute kendalltau, or asks how to score with kendalltau.
Scanned 9/11/2026
Install to Claude Code
npx -y skills add qhjqhj00/research-skills-pool --skill kendalltau --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Kendalltau?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/qhjqhj00-kendalltau)More formats (shields.io, HTML) on the badges page.
---
name: kendalltau
description: Compute the kendalltau metric — provided by scipy.stats. Use when the user has predictions and ground-truth and needs to compute kendalltau, or asks how to score with kendalltau.
metadata:
skill_kind: metric
source_lib: scipy.stats
import_path: scipy.stats.kendalltau
source: library_introspection
---
# kendalltau
> Metric `kendalltau` from `scipy.stats` (scipy.stats.kendalltau)
## When to invoke this skill
The user has predictions + ground truth and asks to evaluate with kendalltau, or
mentions `scipy.stats.kendalltau` directly, or wants the standard scipy.stats implementation.
## Reference signature
```python
from scipy.stats import kendalltau
# kendalltau(x, y, *, nan_policy='propagate', method='auto', variant='b', alternative='two-sided', axis=None, keepdims=False)
```
## Library docstring
```
Calculate Kendall's tau, a correlation measure for ordinal data.
Kendall's tau is a measure of the correspondence between two rankings.
Values close to 1 indicate strong agreement, and values close to -1
indicate strong disagreement. This implements two variants of Kendall's
tau: tau-b (the default) and tau-c (also known as Stuart's tau-c). These
differ only in how they are normalized to lie within the range -1 to 1;
the hypothesis tests (their p-values) are identical. Kendall's original
tau-a is not implemented separately because both tau-b and tau-c reduce
to tau-a in the absence of ties.
Although a naive implementation has O(n^2) complexity, this implementation
uses a Fenwick tree to do the computation in O(n log(n)) complexity.
Parameters
----------
x, y : array_like
Arrays of rankings, of the same shape. If arrays are not 1-D, they
will be flattened to 1-D.
nan_policy : {'propagate', 'omit', 'raise'}
Defines how to handle input NaNs.
- ``propagate``: if a NaN is present in the axis slice (e.g. row) along
which the statistic is computed, the corresponding entry of the output
will be NaN.
- ``omit``: NaNs will be omitted when performing the calculation.
If insufficient data remains in the axis slice along which the
statistic is computed, the corresponding entry of the output will be
NaN.
- ``raise``: if a NaN is present, a ``ValueError`` will be raised.
method : {'auto', 'asymptotic', 'exact'}, optional
Defines which method is used to calculate the p-value [5]_.
The following options are available (default is 'auto'):
* 'auto': selects the appropriate method based on a trade-off
between speed and accuracy
* 'asymptotic': uses a normal approximation valid for large samples
* 'exact': computes the exact p-value, but can only be used if no ties
are present. As the sample size increases, the 'exact' computation
time may grow and the result may lose some precision.
variant : {'b', 'c'}, optional
Defines which variant of Kendall's tau is returned. Default is 'b'.
alternative : {'two-sided', 'less', 'greater'}, optional
Defines the alternative hypothesis. Defaul
```
## Quick recipe
```python
import scipy.stats as _m
score = _m.kendalltau(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)`.
Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.
No comments yet. Be the first to comment!