Similarity encoding for learning with dirty categorical variables

Patricio Cerda, Gaël Varoquaux, Balázs Kégl
6/4/2018
cs.LGcs.AIstat.ML

Official code: pcerda/ecml-pkdd-2018 (11 stars, last commit 2018-06-05).

Abstract

For statistical learning, categorical variables in a table are usually considered as discrete entities and encoded separately to feature vectors, e.g., with one-hot encoding. "Dirty" non-curated data gives rise to categorical variables with a very high cardinality but redundancy: several categories reflect the same entity. In databases, this issue is typically solved with a deduplication step. We show that a simple approach that exposes the redundancy to the learning algorithm brings significant gains. We study a generalization of one-hot encoding, similarity encoding, that builds feature vectors from similarities across categories. We perform a thorough empirical validation on non-curated tables, a problem seldom studied in machine learning. Results on seven real-world datasets show that similarity encoding brings significant gains in prediction in comparison with known encoding methods for categories or strings, notably one-hot encoding and bag of character n-grams. We draw practical recommendations for encoding dirty categories: 3-gram similarity appears to be a good choice to capture morphological resemblance. For very high-cardinality, dimensionality reduction significantly reduces the computational cost with little loss in performance: random projections or choosing a subset of prototype categories still outperforms classic encoding approaches.

View on arXivView PDF

Code Implementations(1)

Scripts for ECML PKDD 2018 article: Similarity encoding for learning with dirty categorical variables

113PythonApr 3, 20188 years ago

Similar Papers

Cite this paper

@article{cerda2018similarity,
  title  = {Similarity encoding for learning with dirty categorical variables},
  author = {Patricio Cerda and Gaël Varoquaux and Balázs Kégl},
  year   = {2018},
  eprint = {1806.00979},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/1806.00979}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/1806.00979.svg)](https://codeofpaper.com/paper/1806.00979)

Discussion