# Feature Engineering

Guides AI coding agents through transforming tabular features for machine learning pipelines using Python and scikit-learn.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 503 installs · ★ 371
- Author: aj-geddes
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/aj-geddes/useful-ai-prompts/tree/HEAD/skills/feature-engineering/SKILL.md
- Updated: 2026-03-04
- HTML: https://affpapa.org/en/nevibecode/skills/aj-geddes-feature-engineering

## What it does

This skill provides reference patterns for tabular data preparation. It guides models through categorical encoding with `OneHotEncoder` or `OrdinalEncoder`, numerical normalization using `StandardScaler` and `RobustScaler`, and polynomial feature creation.

The prompt covers interaction terms, domain transformations like log scaling, binning via `pd.cut`, and temporal feature extraction from dates. Preprocessing steps are organized into a clean `ColumnTransformer` pipeline.

Executing the resulting Python scripts requires `pandas`, `numpy`, `scikit-learn`, `matplotlib`, and `seaborn` installed in your environment.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add aj-geddes/useful-ai-prompts --skill feature-engineering -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/feature-engineering/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/feature-engineering/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add aj-geddes/useful-ai-prompts --skill feature-engineering -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/feature-engineering/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add aj-geddes/useful-ai-prompts --skill feature-engineering -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/feature-engineering/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install aj-geddes/useful-ai-prompts feature-engineering
```

2. **Manually: put the files in place**
- File: `.github/skills/feature-engineering/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add aj-geddes/useful-ai-prompts --skill feature-engineering -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/aj-geddes/useful-ai-prompts --path skills/feature-engineering
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/feature-engineering/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add aj-geddes/useful-ai-prompts --skill feature-engineering -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/aj-geddes/useful-ai-prompts/tree/HEAD/skills/feature-engineering/SKILL.md

## When to use it
- Encode categorical columns using one-hot or ordinal encoding
- Scale numerical features resistant to outliers with RobustScaler
- Create polynomial terms and interaction ratios
- Extract calendar components and weekend flags from date columns
- Bundle data transformations into a scikit-learn ColumnTransformer

## Example prompts
- Build a ColumnTransformer pipeline for numerical and categorical features
- Extract date features and compute interaction ratios for this DataFrame
- Apply RobustScaler and log transforms to continuous features

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 1fdc9ed65486c0a6.

BEGIN THIRD-PARTY FILE 1fdc9ed65486c0a6
````text
---
name: Feature Engineering
description: Create and transform features using encoding, scaling, polynomial features, and domain-specific transformations for improved model performance and interpretability
---

# Feature Engineering

## Overview

Feature engineering creates and transforms features to improve model performance, interpretability, and generalization through domain knowledge and mathematical transformations.

## When to Use

- When you need to improve model performance beyond using raw features
- When dealing with categorical variables that need encoding for ML algorithms
- When features have different scales and require normalization
- When creating domain-specific features based on business knowledge
- When handling skewed distributions or non-linear relationships
- When preparing data for different types of ML algorithms with specific requirements

## Engineering Techniques

- **Encoding**: Converting categorical to numerical
- **Scaling**: Normalizing feature ranges
- **Polynomial Features**: Higher-order terms
- **Interactions**: Combining features
- **Domain-specific**: Business-relevant transformations
- **Temporal**: Time-based features

## Key Principles

- Create features based on domain knowledge
- Remove redundant features
- Scale features appropriately
- Handle categorical variables
- Create meaningful interactions

## Implementation with Python

```python
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.preprocessing import (
    StandardScaler, MinMaxScaler, RobustScaler, PolynomialFeatures,
    OneHotEncoder, OrdinalEncoder, LabelEncoder
)
from sklearn.pipeline import Pipeline
from sklearn.compose import ColumnTransformer
import seaborn as sns

# Create sample dataset
np.random.seed(42)
df = pd.DataFrame({
    'age': np.random.uniform(18, 80, 1000),
    'income': np.random.uniform(20000, 150000, 1000),
    'experience_years': np.random.uniform(0, 50, 1000),
    'category': np.random.choice(['A', 'B', 'C'], 1000),
    'city': np.random.choice(['NYC', 'LA', 'Chicago'], 1000),
    'purchased': np.random.choice([0, 1], 1000),
})

print("Original Data:")
print(df.head())
print(df.info())

# 1. Categorical Encoding
# One-Hot Encoding
print("\n1. One-Hot Encoding:")
df_ohe = pd.get_dummies(df, columns=['category', 'city'], drop_first=True)
print(df_ohe.head())

# Ordinal Encoding
print("\n2. Ordinal Encoding:")
ordinal_encoder = OrdinalEncoder()
df['category_ordinal'] = ordinal_encoder.fit_transform(df[['category']])
print(df[['category', 'category_ordinal']].head())

# Label Encoding
print("\n3. Label Encoding:")
le = LabelEncoder()
df['city_encoded'] = le.fit_transform(df['city'])
print(df[['city', 'city_encoded']].head())

# 2. Feature Scaling
print("\n4. Feature Scaling:")
X = df[['age', 'income', 'experience_years']].copy()

# StandardScaler (mean=0, std=1)
scaler = StandardScaler()
X_standard = scaler.fit_transform(X)

# MinMaxScaler [0, 1]
````
END THIRD-PARTY FILE 1fdc9ed65486c0a6

The third-party file has ended. Everything between the 1fdc9ed65486c0a6 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2956 of 9081 bytes. © aj-geddes · MIT · https://github.com/aj-geddes/useful-ai-prompts/tree/HEAD/skills/feature-engineering/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
