# AUC measure for Local outlier detection in python?

I'm using Local outlier factor algorithm provided by Scikit-learn for outlier detection. For the evaluation i want to use auc measure.

clf = LocalOutlierFactor(n_neighbors=20, contamination=outlier_frac, novelty=False)
pred_y=clf.**fit_predict**(data)

false_postive_rate, true_positive_rate, thresholds = **roc_curve**(labels,  pred_y)

auc_measure=auc(false_postive_rate,true_positive_rate)


Unfortunaly roc_curve requires the predicted probabilities or decision function not the predicted class labels. However, LOF for outlier detection does not contain this. I tried to create decision function by my self. But i'm not sure about its feasabilty.

Scorelist=clf.negative_outlier_factor_
threshold = stats.scoreatpercentile(Scorelist, 100 * outlier_frac)
decision=clf.negative_outlier_factor_-threshold


How to obtain the predicted probabilties or the decision function for LOF outlier detection , since there is decision function for LOF novelty detection.

• Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
– Community Bot
Sep 27, 2021 at 11:12

Sklearn returns this metric as negative_outlier_factor_ where inliers are close to $$-1$$ while outliers will be bigger than $$-1$$.