What is count encoding?
Count encoding replaces each categorical value with the number of times it appears in the dataset.
Count encoding replaces each categorical value with the number of times it appears in the dataset.
Card 1 of 259. Answer: Count encoding replaces each categorical value with the number of times it appears in the dataset.
About · Quizzes · History of AI · To suggest new questions or report an error send me a dm.
Count encoding, also called frequency encoding, replaces each value of a categorical feature with how many times that value appears in the training data. A city that appears 1,200 times becomes 1,200; a city that appears 3 times becomes 3.
It is useful for high-cardinality columns, where one-hot encoding would create thousands of sparse columns. It produces a single numeric column, tree models can split on it directly, and how common a category is often carries signal, as with rare merchant IDs in fraud detection.
Its weakness is that different categories with the same count become indistinguishable, so it is often combined with other encodings. Compute the counts on the training data only and map unseen categories to 0 or 1, otherwise information from the test set leaks into the features.