AI engineering glossary · Feature engineering data prep

What is hashing trick?

Hashing trick (also called Feature hashing): Mapping features, such as categories or words, to a fixed number of columns by applying a hash function to their names and taking the result modulo the column count. It needs no vocabulary and bounded memory, at the cost of occasional hash collisions where different values share a column.

Level: advancedTopic: Feature engineering data prep

Hashing trick: an example

A user-ID feature with millions of values is hashed into 1,024 columns; two different users may collide but the model still trains at fixed size.

Related terms

More Feature engineering data prep terms

Where you learn it

Hashing trick is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.