4
$\begingroup$

I have a training dataset with 140 000 instances with 140 features. Due to the scale of the dataset I'm experiment with letting a model do the anomaly detection and have tried LocalOutlierFactor and IsolationForest. I did not performed any hyperparameter tuning, just executed the functions from sklearn.

lof=LocalOutlierFactor()
yhat=lof.fit_predict(features)

isofor=IsolationForest(n_estimators=100).fit(features)
isolated_instances = iso_f.predict(features)

LOF identified 13 000 outliers and Isolation Forest found 4 000. This discrepancy is of course something I started to think about. Since I'm new to this field of machine learning I wonder how I should think when I fit an anomaly detection model. Is it something I should bear in mind? How can I asses the performance when it's unsupervised? Is it if prediction on test set further down the road is improving? Or is there other methods?

$\endgroup$

1 Answer 1

2
$\begingroup$

First note, that both methods create outlier scores, and such an ordering of the data is often more useful than a simple assignment of a binary value. You should rather assign a threshold for the score yourself.

Second, the defaults are rarely a good choice for individual situations, so you should experiment with them. For that, of course, you need some notion of "performance". You mentioned "prediction on test set further down the road", which sounds like a very good candidate.

$\endgroup$
1
  • $\begingroup$ Thanks. If the values returned from the descion_function is negative, then the predict function returns -1, an outlier according to IsolationForest. The values return from the decscion function span from -0.29 to 0.19. So to be a bit more conservative, I could set the threshold to -0.05 I guess, and see if that improves result. $\endgroup$
    – Henri
    Sep 5, 2022 at 6:48

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.