# Custom Decision Function for Custom Outlier Detection Algorithm

I have built a custom algorithm for semi-supervised anomaly detection and here is my output example as following with probability threshold set to 0.05 and 1 = outlier, 0 = inlier:

X1  X2  X3  Probability Threshold
1   2   3   0.01         1
4   5   6   0.015        1
7   8   9   0.04         1
10  11  12  0.06         0
13  14  15  0.1          0


Now using such data, how can I build the decision function/score similar to the one in scikit-learn?

My ultimate objective is to able to produce precision/recall plot, ROC plot for this algorithm and compare its performance to other scikit-learn and PyOD library algorithms.

The only thing that I was able to come up with so far is to loop through different thresholds of probability and at each iteration set accordingly whether a point is outlier or not and compute precision/recall/tpr/fpr metrics. However, I understand that this is not the proper way to compute the decision function and, thus, it cannot be compared to scikit-learn algorithms.

• You need a continious output for ROC. Cant your just return Probability as the anomaly score? Or possibly 1-p if the score goes the other direction. – jonnor Mar 29 at 18:06
• Hey, I worked out the solution already and is in-line with what you have just mentioned: 1) Inverse probabilities (1-P) 2) Use the probabilities as the anomaly score. Thank you very much sir! – Klaudijus Mar 30 at 14:26