pythonscikit-learnrandom-forestanomaly-detectionisolation-forest

How to use Isolation Forest in python


I'm working on detecting outliers in my unlabeled dataset (data are not labeled as inliers/outliers) and I'm using Isolation Forest in Python (scikit-learn library).
I want to get the anomaly score of the data in my dataset and so I'm using the following code:

if_model = IsolationForest(max_samples=100)
if_model.fit(dataset)
anomaly_score = if_model.score_samples(dataset)

However I have some questions:


Solution