Locality-sensitive-hashing | min-hash and p-stable hash | Hashing library
kandi X-RAY | Locality-sensitive-hashing Summary
kandi X-RAY | Locality-sensitive-hashing Summary
min-hash and p-stable hash
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Searches the nn
- Computes the fingerprint of the data set
- Computes the minimum hash value of a matrix
- Generate the signature for a matrix
- Generate the hash values for a given family
- Generate n - grams of a matrix
- Generate a para
- Generate a list of phonon families
- Compute the K2 K2 hash function
Locality-sensitive-hashing Key Features
Locality-sensitive-hashing Examples and Code Snippets
Community Discussions
Trending Discussions on Locality-sensitive-hashing
QUESTION
I've read the Spark section on Locality Sensitive Hashing and still don't understand some of it:
https://spark.apache.org/docs/latest/ml-features.html#locality-sensitive-hashing
And there's Bucketed Random Projection example for two DataFrames. I have one simple, spatial Dataset of points, like:
(Of course later I will have millions of points) and DataFrame looks like:
...ANSWER
Answered 2020-Feb-03 at 14:50The BucketedRandomProjectionLSH
do exactly what you need. The result hash for each point could be a group value. The only problem is to select proper radius, that will set the size of each bucket. Use .setBucketLength(0.02)
to set the radius. The other small problem is extract the hash from the vector to the column. I use this method: Spark Scala: How to convert Dataframe[vector] to DataFrame[f1:Double, ..., fn: Double)]
Example with your Data
QUESTION
I am looking for a performant algorithm to match a large number of people by location, gender and age according to this data structure:
- Longitude (denotes the persons location)
- Latitude (denotes the persons location)
- Gender (denotes the persons gender)
- Birthdate (denotes the persons birthdate)
- LookingForGender (denotes what the gender the person is looking for)
- LookingForMinAge (denotes what minimum age the person is looking for)
- LookingForMaxAge (denotes what maximum age the person is looking for)
- LookingForRadius (denotes what maximum distance the person is looking for)
- Processed (denotes which other persons this person has already processed)
For any person P the algorithm should return candidates C for which applies:
- Gender of C must be equal P.LookingForGender
- Gender of P must be equal C.LookingForGender
- Birthdate of C must be between P.LookingForMinAge and P.LookingForMaxAge
- Birthdate of P must be between C.LookingForMinAge and C.LookingForMaxAge
- Lat/Long distance between P and C must be smaller or equal P.LookingForRadius
- Lat/Long distance between P and C must be smaller or equal C.LookingForRadius
- Processed of P must not contain C
The algorithm should return the first 100 candidates C in order of distance (Lat/Long). The algorithm should be optimized for both search and updates because people may change their location often.
My current thinking is that k-d tree could be more suitable than locality-sensitive-hashing for these needs and that I should go into this direction.
What would be your advise for me? What should I look for? What risks do you see?
Thanks!
Update:
- Do I prefer to sacrifice space complexity for better time complexity? Yes I prefer to sacrifice space complexity. However I prefer to have a O(log n) solution that I actually understand and can maintain rather than a O(1) solution that I cannot grasp :)
- Does the data fit into main memory? No it does not. The data will be distributed across different nodes of a distributed document database (Azure Cosmos DB SQL API).
- Do you want exact results or are approximate results? Approximate results are OK however age/gender should be filtered exact.
- Added "Processed" to the algorithm, sorry for having missed that!
- How often do people change their location? Users will change their location whenever they start the app and look for candidates. Daily active users will therefore change their location one or multiple times a day. A location change may however be minor so just a few kilometers. From 100 app downloads, 15 users will use the app once or more a a month, and 3 users will use it once or more daily.
ANSWER
Answered 2018-Jul-11 at 20:32Here is some info by Microsoft how to use their spatial indexing ('spatial' is the keyword you want to search for).
The query you are looking for is a k-nearest neighbor query (kNN Search) with k=100.
If you want to serialize the index yourself, have a look at R+tree or R*trees, they are quite good for page based serialization. There are lots of open source example for these trees. Here is my own implementation in Java, unfortunately it does not support Serialization.
About the other indexes:
- I have no experience with LHS, so it can't say much about it. One thing I know though, since it's internally a HashMap, you need to take special care to make it scalable with large amounts of data. This definitely increases complexity. Another problem, I'm not sure LSH is good for kNN search, you will have to look that up.
- KD-trees are very simply and should to the job, but are bad for serialization and can have large memory overhead unless you implement a version that can have more than one entry in each node. KD-Trees can also degenerate when updated often, so they may need rebalancing.
- Otherwise I would suggest quadtrees, for example the qthypercube2. They are also quite simple, very fast in memory, and very well suited for frequent updates, especially if the entries move only a small distance.
QUESTION
ANSWER
Answered 2017-Dec-06 at 11:00I have a few suggestions:
If you use
NGrams
consider more granular tokenizer. The goal here is to correct for misspellings:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Locality-sensitive-hashing
You can use Locality-sensitive-hashing like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page