Contents
How do you get a feature important in Isolation Forest?
So here’s what you can do to get feature importances:
- Determine a threshold for decision path length.
- For each event, loop through the trees in the iForest and select paths that are shorter than the threshold path length.
What is decision function in Isolation Forest?
The IsolationForest ‘isolates’ observations by randomly selecting a feature and then randomly selecting a split value between the maximum and minimum values of the selected feature.
When to use the output of isolation forest?
Having said that, If you are very confident about the results of Isolation Forest classifier and you have a capacity to train another model then you could use the output of Isolation Forest i.e -1/1 values as target-class to train a Random Forest classifier. This will give you feature importance for detecting anomaly.
How to fit isolation forest in scikit learn?
In an unsupervised setting for higher-dimensional data (e.g. 10 variables (numerical and categorical), 5000 samples, ratio of anomalies likely 1% or below but unknown) I am able to fit the isolation forest and retrieve computed anomaly scores (following the original paper and using the implementation in scikit-learn ).
How to calculate the isolation of a tree?
Calculate some kind of ‘isolation metric’ for each node in each tree (such as % of samples split) and get an average of this metric for each splitting feature. After the model has been fit, go through each feature one at a time, randomly permute the data for that feature, and calculate the anomaly scores.
Are there disadvantages to using sklearn in isolation forest?
If you’re using sklearn or other Python based implementations, the biggest disadvantage to this technique is speed. It takes a while to root through all the trees, and if you’re interested in global importances you’ll have to loop though all the events as well.