6
$\begingroup$

I have a dataset that comprises 76 countries, and 6 columns of distinct quantitative variables, which are the mean values of that variable relative to each country:

enter image description here

If I were to take a random sample of the 6 variables - an individual within one of the countries - how would I best go about predicting to which country that individual belongs?

I have a whole separate dataset, with thousands of data points, so I know which country the data belongs to and can thus know for certain whether the algorithm is predicting accurately.

Thus far I have been looking at decision trees and random forest options, but none of the example use cases I've seen translate very well to what I am trying to do. Perhaps I'm looking in the wrong place.

It's not predicting the behavior, as the behavior is already known...it's more about predicting to which country-classification the behavior belongs. Ideas? Comments?

$\endgroup$
4
  • $\begingroup$ Could you share with us the database or a sample of it? I am very interested in this kind of problem. I have some ideas but I would like to apply them to real data $\endgroup$ Commented Apr 30, 2019 at 14:21
  • $\begingroup$ @JuanEstebandelaCalle, photo of the data added, you can get the dataset here: briq-institute.org/global-preferences/downloads $\endgroup$
    – free_road
    Commented Apr 30, 2019 at 15:32
  • $\begingroup$ @JuanEstebandelaCalle also, I used to teach English at International House in Bogota. I like Bogota. What kind of data science are you working on? $\endgroup$
    – free_road
    Commented Apr 30, 2019 at 15:58
  • $\begingroup$ I am working on financial data right now $\endgroup$ Commented Apr 30, 2019 at 19:25

3 Answers 3

3
$\begingroup$

Very interesting question indeed.

I will dare to give you an answer, but I could be changing it if I find a better reasoning about the problem after watching the data.

Your problem is perhaps a problem of multi(many)-label classification, where your label is the country and your data is what you have as "patience", "risktaking", etc.

You could work with random forest or decision trees but on the dataset containing all the individuals (not the summarised by country).

Why on this dataset and not on the summarised? Because the summarised is summarised (!), and only has the data for the mean of "risktaking" (for example) and does not take into account the internal variance of risktakingness inside the countries.

Is important to take this into account, because is possible that risktaking has a variance so large inside a country that is makes the variable meaningless to select a nationality for a person and this is not seen in the summarised database.

If is mandatory that you run the model in the summarised dataset first, then the solution is this:

  • You should run a tree where your node_size parameter is 1, because your summarised dataset has "one individual (country) per label", this is a extreme case where you need a node leaf for every country.
$\endgroup$
2
  • $\begingroup$ Would also like to add that it could be helpful, if not being done already, to convert the categorical target variable into dummy variables (column names are the categories, values are 0 or 1) $\endgroup$
    – m13op22
    Commented May 1, 2019 at 2:07
  • $\begingroup$ The issue I see with trees, is that there is a decision made about a particular attribute of the data which distinguishes it as either one thing, or the other. All the variables I'm working with are standardized - so, yes, I can work with the variance, and certainly I'll adjust to work with individual-level data rather than country-level, however the issue remains: None of these variablesby itself is indicative enough of a certain country. The best we can do is state its proximity to a country's average in terms of standard deviation. And, like you said, variance is often very large. $\endgroup$
    – free_road
    Commented May 2, 2019 at 6:34
2
$\begingroup$

Looking at the description I will go for a 'distance based' approach. Fist, I would produce prototypes of the six variables per country (the summarised table may be an example but there could be more than one single prototype per country). Then, in order to assign a datum to a given country, I would follow a k-nearest or similar approch. Neverthless, producing the prototypes is not necessary to use k-nearest. It only helps to characterise each country. To make a classification based on prototypes, a supervised Self Organising Map (SOM) may be a good approach but a Radial basis function Neural Network (RNN) may work as well. Probabilistic Neural Networks (PNNs) will be an option, although they do not provide prototypes.

$\endgroup$
2
  • $\begingroup$ Thanks for the help. I will read into this a bit more and see if I can try it out. Would you have something more concrete to share with me, any links to relevant info? Thanks again! $\endgroup$
    – free_road
    Commented May 10, 2019 at 12:12
  • $\begingroup$ The kohonen package (R) and related info may be a start. I found a thesis about SOM and python submitted last year (looks pretty complete) google.com/…. knn is a very simple algorithm and is implemented in python. Just google it. About PNNs and RBF-NNs, these were only ideas. I think SOM is better. They can be used to classify and visualize countries' overlaps. $\endgroup$ Commented May 14, 2019 at 7:28
1
$\begingroup$

The SVM.SVC() model is a good choice to go with, though obviously there is more than one option. https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html#sklearn.svm.SVC

The 'Target' values I set as the countries included in the dataset, and then labeled using label_encoder as quantitative variables (1-76).

After defining the model, I was then able to input via 'clf.predict' 6 variables and get a predicted outcome. Clearly, this model was unable to make an accurate prediction first-time around, but we'll work on it.

I'm interested to get more ideas on how to implement this question and to compare the different approaches and improve upon them. Thanks!

X = df[['patience','risktaking','posrecip','negrecip','altruism','trust']].values 
Y = df[['target']].values

label_encoder = LabelEncoder()
Y = label_encoder.fit_transform(Y)

X_train , X_test, y_train, y_test = train_test_split(X,Y)
clf = SVC(C=1.0, kernel='rbf').fit(X_train,y_train)

prediction = int(clf.predict([[2.2529752, 2.466159, 0.95989114, -1.5864599, 0.47468176, 0.9504338]]))
$\endgroup$

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.