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.
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
- Hashing vectorizer
- Haversine distance
- High-cardinality feature
- Hot-deck imputation
- Information value
- Interaction feature
- Interpolation
- IQR method
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.