Skip to content
Back to skills

Play Direction Normalization

ASecurity

Mirror spatial coordinates and angles so all plays face the same direction — removes left/right asymmetry from sports and spatial data

  • 61 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 12, 2026
datapythongo

Security analysis

A100/100

Scanned September 12, 2026

npx -y skills add wenmin-wu/ds-skills --skill play-direction-normalization --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Play Direction Normalization?

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

Security grade badge for Play Direction Normalization
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/wenmin-wu-play-direction-normalization/badge)](https://www.skillsdirectory.com/skills/wenmin-wu-play-direction-normalization)

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-play-direction-normalization
description: Mirror spatial coordinates and angles so all plays face the same direction — removes left/right asymmetry from sports and spatial data
domain: tabular
---

# Play Direction Normalization

## Overview

In spatial datasets (sports tracking, autonomous driving, robotics), events can occur in either direction. Normalize by flipping X-coordinates, orientation, and direction angles so all events face the same way. This halves the effective feature space and prevents models from learning spurious left/right patterns.

## Quick Start

```python
import numpy as np

def normalize_direction(df, direction_col='PlayDirection',
                        x_col='X', orient_col='Orientation',
                        dir_col='Dir', field_length=120.0):
    """Mirror coordinates so all plays go left-to-right."""
    df = df.copy()
    is_left = df[direction_col] == 'left'
    
    # Flip X coordinate
    df.loc[is_left, x_col] = field_length - df.loc[is_left, x_col]
    
    # Flip Y coordinate (optional, for symmetry)
    # df.loc[is_left, 'Y'] = field_width - df.loc[is_left, 'Y']
    
    # Flip angles (0-360 degrees)
    for col in [orient_col, dir_col]:
        flipped = 360.0 - df.loc[is_left, col]
        flipped[flipped == 360.0] = 0.0
        df.loc[is_left, col] = flipped
    
    return df

df = normalize_direction(tracking_data)
```

## Key Decisions

- **X-flip mandatory**: spatial position must be mirrored; Y-flip depends on symmetry of the field
- **Angle flip**: subtract from 360° to mirror orientation; handle 360→0 wraparound
- **Apply before feature engineering**: all derived features (distances, velocities) inherit correct orientation
- **Generalizable**: same pattern for any bidirectional spatial data (court sports, road networks)

## References

- Source: [location-eda-8eb410](https://www.kaggle.com/code/bestpredict/location-eda-8eb410)
- 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.