When is frequency or count encoding preferred over one-hot encoding?

Quick Overview

Asks when replacing a categorical value with its frequency or count works better than one-hot encoding. Tests understanding of high-cardinality features, how tree and linear models use encoded columns, collisions, drift and handling categories unseen in training.

When is frequency or count encoding preferred over one-hot encoding?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Other

When is frequency or count encoding preferred over one-hot encoding for a categorical feature? ```hint Count the columns Estimate how many columns one-hot encoding creates for a feature such as merchant ID, and what that does to memory and to the model. ``` ```hint What the number tells the model Ask when how common a category is says something about the target, and which model types can make use of a single numeric column like that. ``` ### What a Strong Answer Covers - What count or frequency encoding computes, and which data it should be fit on - The situations where it beats one-hot, and why - Its limitations, and how to handle them - When one-hot remains the better choice ### Follow-up Questions - How would you encode a category at inference time that never appeared in training? - Two merchants have the same count but very different fraud rates. What could you add? - How does count encoding compare with target encoding and feature hashing for a feature with a million levels?

Overview: Asks when replacing a categorical value with its frequency or count works better than one-hot encoding. Tests understanding of high-cardinality features, how tree and linear models use encoded columns, collisions, drift and handling categories unseen in training.

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

When is frequency or count encoding preferred over one-hot encoding for a categorical feature?

What a Strong Answer Covers Guidance

  • What count or frequency encoding computes, and which data it should be fit on
  • The situations where it beats one-hot, and why
  • Its limitations, and how to handle them
  • When one-hot remains the better choice

Follow-up Questions Guidance

  • How would you encode a category at inference time that never appeared in training?
  • Two merchants have the same count but very different fraud rates. What could you add?
  • How does count encoding compare with target encoding and feature hashing for a feature with a million levels?