1
$\begingroup$

I am not sure how to interpret the results of my decision tree after I had used target encoding, could someone clarify? The example below doesn't need target encoding just for explanation of my confusion here.

For instance I am trying to classify if a fruit is rotten or not given its age and fruit type. I use target encoding for the fruit column:

enter image description here

I then get the following decision tree with default sklearn decision tree classifier parameters:

enter image description here

I believe after encoding I have lost information about fruit type and I can only say that if fruit_target <= 0.841 then the fruit is rotten if smaller, else not rotten. But then how do i interpret 0.841; what does it mean?

$\endgroup$
3
$\begingroup$

I believe after encoding I have lost information about fruit type and I can only say that if fruit_target <= 0.841 then the fruit is rotten if smaller, else not rotten. But then how do i interpret 0.841; what does it mean?

Recall what the target encoding actually is in this example: it is the share of rotten fruits per fruit type, e.g. $75 \%$ of data points with fruit == pear are estimated to be rotten (I say "estimated" because it depends on the type of target encoding whether this an exact number or an estimate).

Accordingly, you can infer from the decision tree that a data point will be classified as rotten iff its fruit type has more than $0.841 = 84.1\%$ rotten data points in the training set.

$\endgroup$
1
  • $\begingroup$ And at that point, you could always dig into your target encoder to recover which categories actually have fruit_target <= 0.841. $\endgroup$ – Ben Reiniger Sep 12 '20 at 21:46

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.