Skip to main content
skill CX Codex

hierarchical-taxonomy-clustering — Claude Code skill: install

The hierarchical-taxonomy-clustering skill combines similar category paths from multiple sources into a shared hierarchy. Use it to standardize product categories for cross-source analysis.

Apache-2.0 1 installs ★ 1,933 updated 2026-10-24

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add benchflow-ai/skillsbench --skill hierarchical-taxonomy-clustering -a claude-code
Open on GitHub

What hierarchical-taxonomy-clustering does

The skill takes category paths from several sources, cleans and normalizes their labels, then groups related paths. Its output adds unified taxonomy levels to a DataFrame and exports one CSV with the records and another with the category structure.

The workflow has four stages: prepare the data, create weighted embeddings, cluster recursively, and export the results. It relies on the Python packages pandas, numpy, scipy, sentence-transformers, nltk, and tqdm. The setup instructions also download NLTK’s wordnet and omw-1.4 datasets, which the lemmatization step uses.

Run the full workflow with scripts/pipeline.py. Category labels come from weighted word frequency and lemmatization; clustering uses cosine distance at each level. The documented cluster counts are guidance, not fixed requirements for every taxonomy.

What it helps with

  • merge similar category paths from separate sources
  • create a shared hierarchy from inconsistent category labels
  • export categorized records and a taxonomy structure as CSV
  • align product categories for analysis across platforms

Example prompts for the agent

  • Combine category paths from several sources into one taxonomy.
  • Prepare the data and run the full workflow with scripts/pipeline.py.
  • Group the categories by level and export the resulting CSV files.

How to install hierarchical-taxonomy-clustering

1Skills CLI (Vercel)

npx skills add benchflow-ai/skillsbench --skill hierarchical-taxonomy-clustering -a claude-code

2Manually: put the files in place

~/.claude/skills/hierarchical-taxonomy-clustering/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/hierarchical-taxonomy-clustering/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about hierarchical-taxonomy-clustering

How do I install hierarchical-taxonomy-clustering in Claude Code?

Run npx skills add benchflow-ai/skillsbench --skill hierarchical-taxonomy-clustering -a claude-code. The skill file is located at ~/.claude/skills/hierarchical-taxonomy-clustering/SKILL.md.

What does hierarchical-taxonomy-clustering do?

It groups related category paths from different sources into a shared multi-level taxonomy. The results can be exported as CSV files.

Which Python packages does the skill need?

Install pandas, numpy, scipy, sentence-transformers, nltk, and tqdm. The setup also downloads NLTK’s wordnet and omw-1.4 datasets.

Source text

SKILL.md · Apache-2.0
---
name: hierarchical-taxonomy-clustering
description: Build unified multi-level category taxonomy from hierarchical product category paths from any e-commerce companies using embedding-based recursive clustering with intelligent category naming via weighted word frequency analysis.
---

# Hierarchical Taxonomy Clustering

Create a unified multi-level taxonomy from hierarchical category paths by clustering similar paths and automatically generating meaningful category names.

## Problem

Given category paths from multiple sources (e.g., "electronics -> computers -> laptops"), create a unified taxonomy that groups similar paths across sources, generates meaningful category names, and produces a clean N-level hierarchy (typically 5 levels). The unified category taxonomy could be used to do analysis or metric tracking on products from different platform.

## Methodology

1. **Hierarchical Weighting**: Convert paths to embeddings with exponentially decaying weights (Level i gets weight 0.6^(i-1)) to signify the importance of category granularity
2. **Recursive Clustering**: Hierarchically cluster at each level (10-20 clusters at L1, 3-20 at L2-L5) using cosine distance
3. **Intelligent Naming**: Generate category names via weighted word frequency + lemmatization + bundle word logic
4. **Quality Control**: Exclude all ancestor words (parent, grandparent, etc.), avoid ancestor path duplicates, clean special characters

## Output

DataFrame with added columns:
- `unified_level_1`: Top-level category (e.g., "electronic | device")
- `unified_level_2`: Second-level category (e.g., "computer | laptop")
- `unified_level_3` through `unified_level_N`: Deeper levels

Category names use ` | ` separator, max 5 words, covering 70%+ of records in each cluster.

## Installation

```bash
pip install pandas numpy scipy sentence-transformers nltk tqdm
python -c "import nltk; nltk.download('wordnet'); nltk.download('omw-1.4')"
```

## 4-Step Pipeline

### Step 1: Load, Standardize, Filter and Merge (`step1_preprocessing_and_merge.py`)
- **Input**: List of (DataFrame, source_name) tuples, each of the  with `category_path` column
- **Process**: Per-source deduplication, text cleaning (remove &/,/'/-/quotes,'and' or "&", "," and so on, lemmatize words as nouns), normalize delimiter to ` > `, depth filtering, prefix removal, then merge all sources. source_level should reflect the processed version of the source level name
- **Output**: Merged DataFrame with `category_path`, `source`, `depth`, `source_level_1` through `source_level_N`

### Step 2: Weighted Embeddings (`step2_weighted_embedding_generation.py`)
- **Input**: DataFrame from Step 1
- **Output**: Numpy embedding matrix (n_records × 384)
- Weights: L1=1.0, L2=0.6, L3=0.36, L4=0.216, L5=0.1296 (exponential decay 0.6^(n-1))
- **Performance**: For ~10,000 records, expect 2-5 minutes. Progress bar will show encoding status.

### Step 3: Recursive Clustering (`step3_recursive_clustering_naming.py`)
- **Input**: DataFrame + embeddings from Step 2
- **Output**: Assignments dict {index → {level_1: ..., level_5: ...}}
- Average linkage + cosine distance, 10-20 clusters at L1, 3-20 at L2-L5
- Word-based naming: weighted frequency + lemmatization + coverage ≥70%
- **Performance**: For ~10,000 records, expect 1-3 minutes for hierarchical clustering and naming. Be patient - the system is working through recursive levels.

### Step 4: Export Results (`step4_result_assignments.py`)
- **Input**: DataFrame + assignments from Step 3
- **Output**:
  - `unified_taxonomy_full.csv` - all records with unified categories
  - `unified_taxonomy_hierarchy.csv` - unique taxonomy structure

## Usage

**Use `scripts/pipeline.py` to run the complete 4-step workflow.**

See `scripts/pipeline.py` for:
- Complete implementation of all 4 steps
- Example code for processing multiple sources
- Command-line interface
- Individual step usage (for advanced control)

© benchflow-ai · Apache-2.0 · benchflow-ai/skillsbench

Similar skills

All skills for Data and databases →

From the same set22

The whole set →
hex-grid-spatial hex-grid-spatial is a Claude Code skill that calculates neighbours, hex distance, and radius cells on odd-r offset maps for movement or area-of-effect logic. CX Codex +1 1installs python-scala-syntax-mapping python-scala-syntax-mapping is a Claude Code skill that maps Python syntax to Scala for coding assistants translating variables, comprehensions, and control structures. CX Codex +1 1installs image-ocr Use this skill to read text in images with Tesseract OCR through Python. It fits scans, screenshots, and batches of image files. CX Codex +1 1installs audiobook Turns a web article or a text file into an audiobook: pulls the content, cleans it up, and voices it through ElevenLabs, OpenAI TTS or gTTS. CX Codex +1 1installs nanogpt-training nanogpt-training is a Claude Code skill with guidance for training 124M-parameter GPT-2 scale models on a single GPU using Muon, bfloat16, and tokenized dataset shards. CX Codex +1 1installs senior-data-engineer senior-data-engineer — a skill for Claude and other agents: it helps design ETL/ELT and streaming pipelines, generates Airflow DAGs, Kafka configs and data quality checks. CX Codex +1 1installs vulnerability-csv-reporting vulnerability-csv-reporting transforms vulnerability scanner JSON outputs into structured CSV files for compliance audits. CX Codex +1 1installs python-scala-functional The python-scala-functional skill guides Python-to-Scala rewrites in a functional style. Use it for higher-order functions, generators, pattern matching, and error handling. CX Codex +1 1installs

Project sponsors

Companies that keep this analytics open