I have a data set of about ~75 administrative regions. Among many other variables are four specific demographic variables, and a number which represents per-person funding from a government grant.

I am trying to find a way to determine which regions are most similar in demography but which receive the most different funding levels.

I am leaning towards using sklearn.neighbor to find the most similar regions and just visually finding the least similar funding levels, but can I pass it an array of 75 items, with 4 values each?

Is there a better way of doing this?


Edit to include sample table:

id poverty recimm loneparents edu level funding
001 33 44 61 17 155.10
002 29 13 21 1 255.75
003 14 18 24 66 555.74
  • 1
    $\begingroup$ Hey @pubb it would be helpful to see some of your data (a few rows) because they types of variables (nominal, interval, ratio. etc) have an impact on how this might be done $\endgroup$ Commented Sep 30, 2022 at 21:58
  • $\begingroup$ Thanks @bethanyp, edited to include the sample. To be clear, the four demographic variables are percentiles, but I could swap those values out with raw values, ewhich correspond to percents. For example, the area with id 001 might have a poverty rate of say 16%, which corresponds to 33rd percentile, while having a recent immigration rate of 2.4%, which corresponds to the 44th percentile. $\endgroup$
    – pubb
    Commented Oct 3, 2022 at 13:46

2 Answers 2


You could simply plot each of the demographic variables (sorted) vs the funding level. Big jumps at nearby points will be what you are looking for.


I would use the four demographic variables and create a similarity matrix with all other observations.

Then create another similarity matrix based on the funding only.

You can create a function to choose the other observation from your set that maximizes the difference between demographic similarity and funding similarity.

Because similarity is standardized (0-1) you will get the most spread when one is high and one is low. It may not be the most similar in demographics and least similar in funding, but it will be the most different 1:1.

You can then do some clustering to find the set of observations most alike based on demographics alone.

Now you have a groups of similar observations demographically, and from this list you can sort the output of the function by group to find the most dissimilar observation to each cluster member.

Using creative graphing colors by group this should give you some meaningful information.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.