1
$\begingroup$

I have some hand coded feature which is a category with values "High", "Low", and "Normal".

I created this feature myself and my problem performance (classification) increased dramatically when using it with expanding these by dummy variables.

Now since I'm trying random forest, I thought I change "High, Low, Normal" to 1, -1, 0 instead.

Now the same model doesn't learn at all.

I thought it should become easier actually for it to split. Does this have to do with me putting normal to 0?

Thank you for any explanation helping me to understand this.

$\endgroup$
9
  • 2
    $\begingroup$ Should not happen. Can you share the code $\endgroup$
    – 10xAI
    Apr 17 at 15:03
  • $\begingroup$ Sure, which part? It's fairly large $\endgroup$
    – Oliver
    Apr 17 at 15:10
  • $\begingroup$ edit: but if you are sure, I was too that that shouldn't happen. So I may have just have a bug somewhere and look for it $\endgroup$
    – Oliver
    Apr 17 at 15:17
  • 1
    $\begingroup$ how were "high", "low", "normal" encoded in the first place? $\endgroup$
    – Nikos M.
    Apr 17 at 18:40
  • $\begingroup$ @NikosM. I defined a basic threshold function def foo(x) if x > a: return "high" elif x < b return "low" else return "normal. Like that. And I just replaced high, low, normal with 1, -1, 0 for numerical encoding $\endgroup$
    – Oliver
    Apr 17 at 19:22
1
$\begingroup$

It should work: the variable is ordinal so using numerical values makes sense.

So there's a bug somewhere, here are a few suggestions of things to look at:

  • Possibly a type conversion error somewhere: make sure the variable is interpreted as numerical.
  • Check whether the model actually uses the variable: if not then it's likely some type error; if yes then I would investigate what goes wrong: for example it might help to plot this variable vs. target in the two cases where the variable is categorical or numerical.
  • Maybe some difference between the preprocessing of the training and test set: apply the model on the training set, if the performance is good then it's likely that there's something wrong in the preprocessing of the test set.
$\endgroup$
3
  • $\begingroup$ Thank you Erwan, I'll try out your suggestions to find the bug. I have been looking for one since yesterday, this may help me narrow it down. Cheers, Oli $\endgroup$
    – Oliver
    Apr 18 at 10:09
  • 1
    $\begingroup$ @Oliver hope it helps but I probably didn't cover everything, these are just a few thoughts off the top of my head. You can edit the question to add more detail in case you don't find the issue. $\endgroup$
    – Erwan
    Apr 18 at 10:16
  • $\begingroup$ I'll do that, thanks! $\endgroup$
    – Oliver
    Apr 18 at 10:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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