0
$\begingroup$

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.

$\endgroup$
1
  • $\begingroup$ 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. $\endgroup$
    – Community Bot
    Sep 27, 2021 at 11:12

1 Answer 1

0
$\begingroup$

As you said, Local Outlier Factor works by constructing a distance metric that checks whether a point is distant from its neighbours.

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

To answer your question, you can either a) take the negative outlier factor and try to assign a probability based on this or b) just make the probabilities either 1 or 0 (so treat the algorithm as being completely certain).

$\endgroup$
2
  • $\begingroup$ Thank you for your answer. Could you please tell me how can i do the first solution: """take the negative outlier factor and try to assign a probability based on this """ $\endgroup$
    – Imen F
    Sep 27, 2021 at 18:01
  • $\begingroup$ I would multiply the list of values by minus 1 to make it positive. Then subtract the smallest value from everything so that now the smallest value in the list will be zero. Then divide by the biggest value so now the biggest number is one. Now you have a list of numbers which go from zero to one. I have no idea how well that will work in practice for the purposes of your problem though. $\endgroup$
    – Adam Kells
    Sep 27, 2021 at 18:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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