What is the primary trade-off of using feature hashing?

Quick Overview

Explain what feature hashing gives up and what it gains when encoding high-cardinality categorical features. Tests your grasp of hash collisions, memory limits, unseen categories, interpretability, and how the bucket count and signed hashing change the balance.

What is the primary trade-off of using feature hashing?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Other

What is the primary trade-off of using feature hashing? Feature hashing (the hashing trick) maps each feature value to one of a fixed number of columns with a hash function. Explain what you give up and what you get in return. ```hint Compare with one-hot encoding Compare what a one-hot encoder has to fit and store with what a hash function needs, then ask what happens when two values land in the same bucket. ``` ### What a Strong Answer Covers - What hashing gains over a stored vocabulary or one-hot encoding. - What collisions do to the learned model, and when they matter most. - The effect on interpretability and debugging. - The settings that move the balance, and what each one costs. ### Follow-up Questions - How would you choose the number of buckets for a feature with about 10 million distinct values? - What goes wrong if training and serving compute the hash differently, and how do you prevent it? - How does hashing IDs into an embedding table in a deep model relate to the same trade-off?

Overview: Explain what feature hashing gives up and what it gains when encoding high-cardinality categorical features. Tests your grasp of hash collisions, memory limits, unseen categories, interpretability, and how the bucket count and signed hashing change the balance.

General logo
General
Nov 24, 2026
mediumMachine Learning EngineerOtherMachine Learning
0
0

What is the primary trade-off of using feature hashing?

Feature hashing (the hashing trick) maps each feature value to one of a fixed number of columns with a hash function. Explain what you give up and what you get in return.

What a Strong Answer Covers Guidance

  • What hashing gains over a stored vocabulary or one-hot encoding.
  • What collisions do to the learned model, and when they matter most.
  • The effect on interpretability and debugging.
  • The settings that move the balance, and what each one costs.

Follow-up Questions Guidance

  • How would you choose the number of buckets for a feature with about 10 million distinct values?
  • What goes wrong if training and serving compute the hash differently, and how do you prevent it?
  • How does hashing IDs into an embedding table in a deep model relate to the same trade-off?