colors-normalized / README.md
NacerKr's picture
Upload README.md with huggingface_hub
5391cb5 verified
|
Raw
History Blame Contribute Delete
6.09 kB
metadata
license: mit
language:
  - en
  - fr
tags:
  - color
  - color-normalization
  - multilingual
  - ecommerce
  - text-classification
pretty_name: Color Names Normalized
size_categories:
  - 10K<n<100K
task_categories:
  - text-classification
configs:
  - config_name: default
    data_files:
      - split: train
        path: data/colors_normalized.parquet

Color Names Normalized

A dataset for normalizing messy, multilingual, free-text color names to a small, fixed vocabulary. Real-world color attributes — product feeds, marketplace listings, survey answers — are free text with thousands of variants. This dataset maps 38,112 real-world color names (English and French) to a strict 20-color base palette — e.g. "rouge", "dark navy", "burgundy", "whispering grasslands" all resolve to a canonical base color — so color data becomes groupable, filterable, and analyzable.

Each color name comes with its hex code and was assigned to the perceptually closest palette color using the CIEDE2000 color-difference formula in CIELAB space (D65).

Use cases

  • E-commerce catalogs: power color filters and facets from free-text product attributes instead of maintaining hand-written mapping tables.
  • Analytics: aggregate sales or inventory by 20 base colors rather than thousands of vendor-specific shade names.
  • Search & matching: treat "navy", "midnight", and "bleu marine" as the same bucket for retrieval, dedup, or entity matching.
  • ML features: turn a high-cardinality text column into a clean 20-class categorical feature.

Quick start

import pandas as pd

# Load directly from the Hub
df = pd.read_parquet(
    "hf://datasets/NacerKr/colors-normalized/data/colors_normalized.parquet"
)

# Build a normalization lookup: messy name -> base color
lookup = df.set_index(["name", "language"])["base_color"]
lookup.loc[("rouge", "fr")]      # 'red'
lookup.loc[("burgundy", "en")]   # 'brown'

Or with the datasets library:

from datasets import load_dataset

ds = load_dataset("NacerKr/colors-normalized", split="train")

Names in the dataset are lowercased and whitespace-normalized — apply .str.strip().str.lower() (and collapse inner whitespace) to your raw color values before joining.

Schema

Column Type Description
name string Color name, lowercased and whitespace-normalized
hex string Hex code of the named color, uppercase #RRGGBB
language string en or fr
source string color-names, color-pedia, or french-gist
base_color string Assigned base palette color (one of 20 labels)
base_hex string Hex code of the assigned base color
delta_e float32 CIEDE2000 distance between hex and base_hex (0 = exact)

38,112 rows — 37,877 English, 235 French. Median ΔE₀₀ to the assigned base color is 12.4 (p90 = 19.6). Unique on (name, language).

Base palette (20 labels)

The palette is the basic palette from colorjs/color-namer (MIT), minus fuchsia, which is an exact duplicate of magenta (#FF00FF).

Label Hex Label Hex
black #000000 tan #D2B48C
blue #0000FF violet #EE82EE
cyan #00FFFF beige #F5F5DC
green #008000 gold #FFD700
teal #008080 magenta #FF00FF
turquoise #40E0D0 orange #FFA500
indigo #4B0082 pink #FFC0CB
gray #808080 red #FF0000
purple #800080 white #FFFFFF
brown #A52A2A yellow #FFFF00

Methodology

  1. Merge three permissively-licensed color-name sources (below) into (name, hex) pairs tagged with language and source.
  2. Clean: lowercase and whitespace-normalize names; validate and normalize hex to uppercase #RRGGBB; drop junk names that embed raw hex codes (~15k generation artifacts in color-pedia); deduplicate on (name, language) with source priority color-namescolor-pediafrench-gist.
  3. Assign: convert every hex and the 20 palette anchors from sRGB to CIELAB (D65 white point), compute the full N×20 CIEDE2000 distance matrix in one vectorized numpy pass, and take the argmin. The CIEDE2000 implementation is validated against the Sharma et al. (2005) published test pairs.

Sources & attribution

Source Contribution License
boltuix/color-pedia English color names + hex MIT
BatteRaquette58/color-names (derived from meodai/color-names) English color names + hex MIT
angelodlfrtr's french_colors.json gist French color names + hex not stated (attribution given)
colorjs/color-namer 20-label base palette MIT

The EPFL Multi-lingual Color Thesaurus was evaluated as an additional French source but deliberately excluded: its CC BY-NC-SA 3.0 license (non-commercial) is incompatible with commercial use.

Limitations

  • Nearest-anchor artifacts: assignment is purely geometric against 20 fixed anchor points. A few results differ from human intuition — e.g. navy blue (#000080) lands on indigo rather than blue, and some saturated pinks land on violet/magenta because the pink anchor (#FFC0CB) is very pale. Use delta_e as a confidence signal (larger = less certain).
  • French coverage is small (235 names) relative to English.
  • Names are lowercased; match case-insensitively against your raw data.

License

Released under the MIT License.