I have two datasets A and B. What I would like to do is for each observation in A, I would like to find 5 observations from B that are closest and match to A.
How should I start?
Thank you for your help!
Data Science Stack Exchange is a question and answer site for Data science professionals, Machine Learning specialists, and those interested in learning more about the field. It only takes a minute to sign up.Sign up to join this community
Look at "unsupervised nearest neighbor" algorithm. This algorithm needs records to be first expressed as vectors so that "distance" between two point so that it makes sense to talk about distance between two points. For each point in data A, you can look for K nearest neighbors from data B, after expressing all observations in a common vector space.
You will have to handle categorical columns correctly (say using one-hot encoding), as there's no concept of (direct) distance between categorical data.
Python scikit-learn library has a good implementation of this algorithm. Reading the API documentation is a good place to start.