Skip to content
Back to skills

Brand Name Recovery From Title

ASecurity

Recover missing categorical values by matching words in a related text field against a known vocabulary built from the full dataset

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

Security analysis

A100/100

Scanned September 12, 2026

npx -y skills add wenmin-wu/ds-skills --skill brand-name-recovery-from-title --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Brand Name Recovery From Title?

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

Security grade badge for Brand Name Recovery From Title
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/wenmin-wu-brand-name-recovery-from-title/badge)](https://www.skillsdirectory.com/skills/wenmin-wu-brand-name-recovery-from-title)

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-brand-name-recovery-from-title
description: Recover missing categorical values by matching words in a related text field against a known vocabulary built from the full dataset
---

# Brand Name Recovery from Title

## Overview

When a high-cardinality categorical (e.g. brand) has many missing values but a related free-text field (e.g. product title) often contains the category value, recover missing entries by matching title words against the known vocabulary of that categorical. This is a lightweight, domain-agnostic imputation that can recover a large fraction of missing values without a model.

## Quick Start

```python
import pandas as pd

full = pd.concat([train, test])
known_brands = set(full['brand_name'].dropna().unique())

def recover_brand(row):
    if pd.isna(row['brand_name']) or row['brand_name'] == 'missing':
        for word in row['name'].split():
            if word in known_brands:
                return word
    return row['brand_name']

train['brand_name'] = train.apply(recover_brand, axis=1)
test['brand_name'] = test.apply(recover_brand, axis=1)
```

## Workflow

1. Build vocabulary: collect all unique non-null values from the categorical column across train+test
2. For each row with a missing categorical, tokenize the related text field
3. Check each token against the vocabulary set (O(1) lookup)
4. Return the first match, or keep as missing if no match found
5. Apply before encoding — the recovered values are real categories

## Key Decisions

- **Match order**: first token match wins; alternatively pick the rarest brand for specificity
- **Case sensitivity**: lowercase both sides if brand casing varies
- **Multi-word brands**: split brands into n-grams if brands contain spaces
- **Transductive**: uses test set vocab — acceptable since it's the categorical's own values, not the target

## References

- [Mercari RNN + 2Ridge models](https://www.kaggle.com/code/valkling/mercari-rnn-2ridge-models-with-notes-0-42755)

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.