How to identify the subset of a large dataset that has a similar distribution with the another dataset I am trying to implement transfer learning to make predictions on test set using a model trained on another dataset collected from a different sample.
For this, I need to identify the subset of training data that has a similar distribution with the test data.
I wonder if there are any methods to achieve this in sklearn or python. R also works. Any suggestions or ideas?
 A: If you have density functions $p(x)$ and $q(x)$ for your training and testing distributions, you can subsample the training set to match the distribution of the testing distribution as described in this question.  The linked question provides code for doing exactly this in the case where you have a single dimension, and as long as the dimension is not too high for density estimation to work, it may work in your case. 
A: I am a novice Python user, but I do use R a great deal. I know that isn't what you were looking for and this suggestion may only tangentially relate to your question. That all being said, you could consider using a model-based clustering approach. As opposed to say, k-means, which does not incorporate variable distributions in its clustering decisions, something like a latent profile or latent class analysis may be more in line with what you are looking for as centroids, variances, and covariances are all considered when probabilistically assigning cases to subpopulations. These approaches can distinguish between two groups that may be similar in their average scores on a given set of variables, but show evidence of different variances and covariances on those same variables (not a perfect mapping on to your question of matching distributions, but perhaps a step closer?) 
If possible, you may also want to reduce the dimensionality of the data set using something like a principal components analysis, though I understand that may not an option. 
I am less certain about the capabilities of Python, but R the mclust package allows for model-based clustering. 
