Skip to content
Back to skills

Crps Cdf Loss

ASecurity

Model cumulative distribution via softmax output layer and CRPS loss — for probabilistic regression over discrete bins

  • 61 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 12, 2026
datapythonbackend

Works with

  • cli

Security analysis

A100/100

Scanned September 12, 2026

npx -y skills add wenmin-wu/ds-skills --skill crps-cdf-loss --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Crps Cdf Loss?

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

Security grade badge for Crps Cdf Loss
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/wenmin-wu-crps-cdf-loss/badge)](https://www.skillsdirectory.com/skills/wenmin-wu-crps-cdf-loss)

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: tabular-crps-cdf-loss
description: Model cumulative distribution via softmax output layer and CRPS loss — for probabilistic regression over discrete bins
domain: tabular
---

# CRPS CDF Loss

## Overview

When the target is a probability distribution (e.g., "what is the CDF of yards gained?"), encode the label as a step function over discrete bins, use a softmax output layer, then train with Continuous Ranked Probability Score (CRPS) loss. CRPS penalizes the squared difference between predicted and true CDFs, rewarding both calibration and sharpness.

## Quick Start

```python
import numpy as np
import tensorflow.keras.backend as K

def crps_loss(y_true, y_pred):
    """CRPS loss on cumulative softmax output."""
    return K.mean(K.square(y_true - K.cumsum(y_pred, axis=1)), axis=1)

def encode_cdf_target(values, n_bins=199, offset=99):
    """Encode scalar targets as step-function CDFs.
    
    Args:
        values: array of integer targets
        n_bins: number of discrete bins
        offset: bin index corresponding to target=0
    """
    y = np.zeros((len(values), n_bins))
    for i, v in enumerate(values):
        y[i, v + offset:] = 1.0
    return y

# Model
output = Dense(199, activation='softmax')(hidden)
model.compile(optimizer='adam', loss=crps_loss)

# CRPS evaluation callback
y_pred_cdf = np.clip(np.cumsum(model.predict(X_val), axis=1), 0, 1)
y_true_cdf = np.clip(np.cumsum(y_val, axis=1), 0, 1)
crps = np.mean(np.sum((y_true_cdf - y_pred_cdf) ** 2, axis=1)) / n_bins
```

## Key Decisions

- **Softmax output**: guarantees predicted PDF sums to 1; cumsum gives valid CDF
- **Bin count**: 199 for yards (−99 to +99); adjust to match your target range
- **Clip cumsum**: numerical safety — ensures CDF stays in [0, 1]
- **CRPS vs MSE**: CRPS is a proper scoring rule for distributions; MSE on CDF works but lacks calibration incentive

## References

- Source: [neural-networks-feature-engineering-for-the-win](https://www.kaggle.com/code/bgmello/neural-networks-feature-engineering-for-the-win)
- Competition: NFL Big Data Bowl

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.