# Performance difference between decision trees and logistic regression when one of the features is a string

I have a set of features, one of which is a string. I convert the string to an integer by treating the string as a base 36 number (I only use the first 13 characters). Then I can use DecisionTrees since in the sklearn implementation you need to convert it to a number. When I tried a different model, say Logistic Regression, performance drops drastically, say from 80% to 30% accuracy.

I might have accepted this result if I had been able to use the strings as such in the DecisionTrees model, but since I used the same string to integer conversion for both models, why such great difference?

I cannot go into the details, but let me provide you with an analogy. Let's say you are classifying millions of objects by their usefulness. So you say hammers are 4, screwdrivers 6, washers 10, etc. Of course you have more than one screwdriver, and sometime you forget and give it a value of 5, or something else. The model goes through millions of example, and then makes a prediction about the number for each object. I converted the names into integers, as I explained, and decision trees gives me an 80% accuracy, linear regression 30%. I assume that the problem is that linear regression tries to figure out some mathematical rule that does not exist. But why is decision trees immune from this problem?

• Add details to your question. What type of data you are working on? Are the features highly correlated? Did you use feature scaling while implementing LR? Jan 25, 2017 at 10:43
• Logistic regression vs Linear Regression, these are very different models. Please clarify which of them you use. Jan 25, 2017 at 16:08
• Take a look at this: datascience.stackexchange.com/questions/14666/…. Jan 25, 2017 at 16:15
• You might be falling into the dummy variable trap. Jan 25, 2017 at 16:16
• The string similarity metric that you choose is quite unconventional. Could you please clarify why it is a reasonable choice in this case. Note that differences in the first charter are much (exponentially) heavier than differences in the last. Aug 21, 2018 at 4:34