# How to use LOF for outlier detection as I have training and test dataset?

I want to use the Local Outlier Factor (LOF) algorithm for outlier detection but it simply finds outliers on unlabed data as whole and you do not need to have a training and test set. However in my case I expect to get some knowledge from the training set and test this knowledge on test data (it seems like an ordinary classification problem :) ). Is there any way to use the LOF or any other anomaly detection algorithm via training and test set? At least, how can I get some statistics for my test set specifically? What is the methodology of using these with separated data?

• how are your test/training set constructed? For example, are they random partition of the same dataset or are they coming from two temporally disjoint datasets (e.g. the test set is composed of observations samples before a certain date and the train set of observations after that date)? – user603 Feb 26 '13 at 22:21

You can try this paper [1]. This work is about matching train and test distribution matching and estimation of density ratio $P_{test}(x)/P_{train}(x)$. However, it is designed in such a way that instead of computing the density ratio of train to test, it computes density ratio of train to some convex combination of train and test distribution i.e $\alpha P_{train} + (1 - \alpha)P_{test}$. Now, by setting $\alpha$ close to 1, they are able to do outlier detection and in fact it is one of their experiments in their paper.