Density-based k-nearest neighbors

To demonstrate how LOF calculates scores, we'll first split the dataset into training and testing sets by using the testCV(int, int) function. The first parameter specifies the number of folds, while the second parameter specifies which fold to return:

// split data to train and test 
Instances trainData = dataset.testCV(2, 0); 
Instances testData = dataset.testCV(2, 1); 

The LOF algorithm is not a part of the default Weka distribution, but it can be downloaded through Weka's package manager at http://weka.sourceforge.net/packageMetaData/localOutlierFactor/index.html.

The LOF algorithm has two implemented interfaces: as an unsupervised filter that calculates LOF values (known unknowns), and as a supervised ...

Get Machine Learning in Java - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.