Created
April 17, 2024 09:42
-
-
Save simonespa/2347de028788ee2eba1d286ea15ec4e7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from category_encoders import HashingEncoder | |
| N = unique[column] | |
| encoder = HashingEncoder( | |
| cols=[column], | |
| n_components=math.ceil(math.log2(N)), # the number of bits required to encode N elements | |
| hash_method='sha256' # https://docs.python.org/3/library/hashlib.html#constructors | |
| ) | |
| df = encoder.fit_transform(df) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment