Skip to content
Back to skills

Criticalsuccessindex

ASecurity

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

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

Security analysis

A100/100

Scanned September 11, 2026

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

Installs into .claude/skills of the current project.

Are you the author of Criticalsuccessindex?

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

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

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

# criticalsuccessindex

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

## When to invoke this skill

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

## Reference signature

```python
from torchmetrics import CriticalSuccessIndex

# CriticalSuccessIndex(threshold: float, keep_sequence_dim: Optional[int] = None, **kwargs: Any) -> None
```

## Library docstring

```
Calculate critical success index (CSI).

Critical success index (also known as the threat score) is a statistic used weather forecasting that measures
forecast performance over inputs binarized at a specified threshold. It is defined as:

.. math:: \text{CSI} = \frac{\text{TP}}{\text{TP}+\text{FN}+\text{FP}}

Where :math:`\text{TP}`, :math:`\text{FN}` and :math:`\text{FP}` represent the number of true positives, false
negatives and false positives respectively after binarizing the input tensors.

Args:
    threshold: Values above or equal to threshold are replaced with 1, below by 0
    keep_sequence_dim: Index of the sequence dimension if the inputs are sequences of images. If specified,
        the score will be calculated separately for each image in the sequence. If ``None``, the score will be
        calculated across all dimensions.

Example:
    >>> import torch
    >>> from torchmetrics.regression import CriticalSuccessIndex
    >>> x = torch.Tensor([[0.2, 0.7], [0.9, 0.3]])
    >>> y = torch.Tensor([[0.4, 0.2], [0.8, 0.6]])
    >>> csi = CriticalSuccessIndex(0.5)
    >>> csi(x, y)
    tensor(0.3333)

Example:
    >>> import torch
    >>> from torchmetrics.regression import CriticalSuccessIndex
    >>> x = torch.Tensor([[[0.2, 0.7], [0.9, 0.3]], [[0.2, 0.7], [0.9, 0.3]]])
    >>> y = torch.Tensor([[[0.4, 0.2], [0.8, 0.6]], [[0.4, 0.2], [0.8, 0.6]]])
    >>> csi = CriticalSuccessIndex(0.5, keep_sequence_dim=0)
    >>> csi(x, y)
    tensor([0.3333, 0.3333])
```

## Quick recipe

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