For context, I've been using feature hashing for a rapid text classifier with a very small number of features (2000, it is very small on purpose). I noticed that some of the results were a bit wonky due to collisions and was wondering if it would be possible to select a better hash (varying the hash function and random key) to have more "natural" collisions.
To select a better hash empirically I've settled on, for a given dataset, measuring the similarity of the distribution of the hashing features versus neural features Specifically I want to capture:
- How well are neighborhoods preserved?
- How well preserved are distances between neighborhoods?
Here's what I've tried so far:
- Kendall's Tau, captures 1. but not 2. It's also relatively expensive to compute (~20 seconds on an older computer)
- Gromov-Wasserstein, looks at distribution rather than specific words. Similar time to 1
- Solving for a linear transformation between the two (Least Squares). Not sure how to transform that into a meaningful metric (residual, magnitude?). Cost is variable.
Beyond a method to measure embedding space similarity I'd also be open to other methods of picking better hashes