I'm running sklearn's IsolationForest on a dataset containing 2 classes of data, one that I know is the anomaly (~1.5% of the entire dataset), the other is the normal dataset.

I'm using this (shuffled) dataset to gauge if my isolation forest model is accurate, i.e. I would expect to see most of the anomaly data flagged by the model. However, that is not the case, as out of the 1.18% flagged as anomalous, only about 7% of those flagged belongs to the anomalous class - most of the anomalous data was not flagged.

I'm trying to understand how my model is doing the predictions. Besides SHAP, can I look at the feature importance or visualize one of the trees? IsolationForest doesn't seem to have the feature_importances_ attribute like Random Forest.

On a more fundamental level, does my approach of using this mixed dataset to test the performance of my model even make sense?

(I'm not using a supervised model because this is the only time I would have data I know should be anomalous, and I'm using this as an opportunity to see how my model performs.)

  • $\begingroup$ What kind of features do you have? $\endgroup$
    – Jon Nordby
    Aug 12, 2022 at 13:29
  • $\begingroup$ Can you provide a plot of the anomaly scores, colored by the label (anomalous/not)? $\endgroup$
    – Jon Nordby
    Aug 12, 2022 at 13:30


Your Answer

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