5
$\begingroup$

Isolation Forest is widely used when dealing with outlier/anomaly detection when we have no labels. The theory behind is that making random split at random points and counting how many splits you do to isolate a feature will help you determine if an instance is or not an outlier.

I have categorical features and I am not sure how to deal with them:

  • Label Encoding: Will misrepresent the data in euclidean space.
  • One Hot Encoding: Will give me more features and since the source code first selects the columns and then the values, it will give a non-realistic probability for my algorithm to select the one hot encoded
  • Target Encoding wont work since we have no target

How to properly encode categorical features in Isolation Forest? Could we encode categorical features in a space that suits the algorithm

$\endgroup$
8
  • 2
    $\begingroup$ How about other unsupervised ways of encoding e.g. Binary, Count, Hashing etc. (avaiable at github.com/scikit-learn-contrib/category_encoders)? I think Catboost uses some of these methods to encode categorical variables automatically, well that is an gradient boosting trees, but I am mentioning so that you can use them too in Isolation Forest. $\endgroup$ May 5, 2020 at 21:05
  • 1
    $\begingroup$ Yes, there is a lot of categoy encoders. My question is what is the best and why? Catboost Encoded is target encoding but with some fancy functionalities, but at the end target encoding, so it requires a label $\endgroup$ May 7, 2020 at 6:16
  • 1
    $\begingroup$ @TwinPenguins arxiv.org/abs/2105.13783 $\endgroup$ Nov 7, 2021 at 17:57
  • 1
    $\begingroup$ Your own paper/method, bravo! Will have a look. Is it already included in sktools? $\endgroup$ Nov 8, 2021 at 7:59
  • 1
    $\begingroup$ It is included in sktools, also in category_encoders. Even thought category_encoders needs to do a package release to be able to use it. $\endgroup$ Nov 8, 2021 at 8:05

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.