Skip to content
Back to skills

Minkowskidistance

ASecurity

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

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

Works with

  • cli

Security analysis

A100/100

Scanned September 11, 2026

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

Installs into .claude/skills of the current project.

Are you the author of Minkowskidistance?

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

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

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

# minkowskidistance

> Metric `MinkowskiDistance` from `torchmetrics` (torchmetrics.MinkowskiDistance)

## When to invoke this skill

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

## Reference signature

```python
from torchmetrics import MinkowskiDistance

# MinkowskiDistance(p: float, **kwargs: Any) -> None
```

## Library docstring

```
Compute `Minkowski Distance`_.

.. math::
    d_{\text{Minkowski}} = \sum_{i}^N (| y_i - \hat{y_i} |^p)^\frac{1}{p}

where
    :math: `y` is a tensor of target values,
    :math: `\hat{y}` is a tensor of predictions,
    :math: `\p` is a non-negative integer or floating-point number

This metric can be seen as generalized version of the standard euclidean distance which corresponds to minkowski
distance with p=2.

Args:
    p: int or float larger than 1, exponent to which the difference between preds and target is to be raised
    kwargs: Additional keyword arguments, see :ref:`Metric kwargs` for more info.

Example:
    >>> from torchmetrics.regression import MinkowskiDistance
    >>> target = tensor([1.0, 2.8, 3.5, 4.5])
    >>> preds = tensor([6.1, 2.11, 3.1, 5.6])
    >>> minkowski_distance = MinkowskiDistance(3)
    >>> minkowski_distance(preds, target)
    tensor(5.1220)
```

## Quick recipe

```python
import torchmetrics as _m
score = _m.MinkowskiDistance(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.