Given two features, one a string and other a categorical, what are the encoding rules? I have two features in my dataset I'm using to help predict a binary outcome. Based on my features, I'm trying to figure out which I need to drop a dummy to avoid the dummy trap.


*

*First feature is a string of "tags". There are 239 unique tags, which are seen in the dataset as comma separated sets of 1 to 9 tags.


*

*What I did here was split them by the delimiter into a vector of 1s or 0s using MultiLabelBinarizer(). So these will be represented as a vector of length 239 of 1s and 0s.


*Second feature is country codes, eg. (US, MX, FR, etc.). There are 26 unique country codes.


*

*These are represented as a single country for each row of the dataset. I plan on one hot encoding these as well to 0s or 1s.



I'm fairly sure I don't need to drop anything for the first feature. It's so sparse, that I can't imagine it requiring that.
Where I'm stuck though is about the country code, I can't understand if I need to drop one column or if I can just keep them all.
If I don't drop, in the end I will have 26 + 239 columns of ones and zeros, mostly zeros. If I do drop one, I will have 25 + 239 of ones and zeros.
 A: do the usual one hot encoding you are mentioning, then you can check if the sum of the (ones and zeros) of your new vector add to a constant for all your observations.  If so, then you can eliminate one categorical variable as its not independent.    For example:  encoding Men/Woman for Gender attribute of persons would always sum to one, in this case you can remove one (Man or Woman), thats the textbook example of dummy variable trap.  
If you have some insights on your data, you can also see directly if you have the dummy trap (does each observation in your data is assigned to only one country?, and, Do all observations have one country assigned?, if yes to both, then you should remove one country when encoding). 
If you have observations with missing values for the categorical features you would need to think a bit how to implement things.  If its Gender it is clear that missing values should either be male or female, but for countries might be different.  And this would impact the dummy variable thing.  
cheers
