Skip to content
Back to skills

Runningsum

ASecurity

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

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

Security analysis

A100/100

Scanned September 11, 2026

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

Installs into .claude/skills of the current project.

Are you the author of Runningsum?

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

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

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

# runningsum

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

## When to invoke this skill

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

## Reference signature

```python
from torchmetrics import RunningSum

# RunningSum(window: int = 5, nan_strategy: Union[Literal['error', 'warn', 'ignore', 'disable'], float] = 'warn', **kwargs: Any) -> None
```

## Library docstring

```
Aggregate a stream of value into their sum over a running window.

Using this metric compared to `SumMetric` allows for calculating metrics over a running window of values, instead
of the whole history of values. This is beneficial when you want to get a better estimate of the metric during
training and don't want to wait for the whole training to finish to get epoch level estimates.

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

- ``value`` (:class:`~float` or :class:`~torch.Tensor`): a single float or an tensor of float values with
  arbitrary shape ``(...,)``.

As output of `forward` and `compute` the metric returns the following output

- ``agg`` (:class:`~torch.Tensor`): scalar float tensor with aggregated sum over all inputs received

Args:
    window: The size of the running window.
    nan_strategy: options:
        - ``'error'``: if any `nan` values are encountered will give a RuntimeError
        - ``'warn'``: if any `nan` values are encountered will give a warning and continue
        - ``'ignore'``: all `nan` values are silently removed
        - ``'disable'``: disable all `nan` checks
        - a float: if a float is provided will impute any `nan` values with this value

    kwargs: Additional keyword arguments, see :ref:`Metric kwargs` for more info.

Raises:
    ValueError:
        If ``nan_strategy`` is not one of ``error``, ``warn``, ``ignore``, ``disable`` or a float

Example:
    >>> from torch import tensor
    >>> from torchmetrics.aggregation import RunningSum
    >>> metric = RunningSum(window=3)
    >>> for i in range(6):
    ...     current_val = metric(tensor([i]))
    ...     running_val = metric.compute()
    ...     total_val = tensor(sum(list(range(i+1))))  # total sum over all samples
    ...     print(f"{current_val=}, {running_val=}, {total_val=}")
    current_val=tensor(0.), running_val=tensor(0.), total_val=tensor(0)
    current_val=tensor(1.), running_val=tensor(1.), total_val=tensor(1)
    current_val=tensor(2.), running_val=tensor(3.), total_val=tensor(3)
    current_val=tensor(3.), running_val=tensor(6.), total_val=tensor(6)
    current_val=tensor(4.), running_val=tensor(9.), total_val=tenso
```

## Quick recipe

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