
O - the type of DatabaseObjects handled by this AlgorithmD - Distance type@Title(value="LOF: Local Outlier Factor") @Description(value="Algorithm to compute density-based local outlier factors in a database based on the neighborhood size parameter \'k\'") @Reference(authors="M. M. Breunig, H.-P. Kriegel, R. Ng, and J. Sander", title="LOF: Identifying Density-Based Local Outliers", booktitle="Proc. 2nd ACM SIGMOD Int. Conf. on Management of Data (SIGMOD \'00), Dallas, TX, 2000", url="http://dx.doi.org/10.1145/342009.335388") public class FlexibleLOF<O,D extends NumberDistance<D,?>> extends AbstractAlgorithm<OutlierResult> implements OutlierAlgorithm
Flexible variant of the "Local Outlier Factor" algorithm.
This implementation diverts from the original LOF publication in that it allows the user to use a different distance function for the reachability distance and neighborhood determination (although the default is to use the same value.)
The k nearest neighbors are determined using the parameter
DistanceBasedAlgorithm.DISTANCE_FUNCTION_ID
, while the reference set used in reachability distance computation is
configured using FlexibleLOF.Parameterizer.REACHABILITY_DISTANCE_FUNCTION_ID.
The original LOF parameter was called "minPts". For consistency
with the name "kNN query", we chose to rename the parameter to k.
Flexible LOF allows you to set the two values different, which yields the
parameters FlexibleLOF.Parameterizer.KREF_ID (-lof.krefer) and
FlexibleLOF.Parameterizer.KREACH_ID (-lof.kreach)
Reference:
M. M. Breunig, H.-P. Kriegel, R. Ng, J. Sander: LOF: Identifying
Density-Based Local Outliers.
In: Proc. 2nd ACM SIGMOD Int. Conf. on Management of Data (SIGMOD'00),
Dallas, TX, 2000.
| Modifier and Type | Class and Description |
|---|---|
static class |
FlexibleLOF.LOFResult<O,D extends NumberDistance<D,?>>
Encapsulates information like the neighborhood, the LRD and LOF values of
the objects during a run of the
FlexibleLOF algorithm. |
static class |
FlexibleLOF.Parameterizer<O,D extends NumberDistance<D,?>>
Parameterization class.
|
| Modifier and Type | Field and Description |
|---|---|
protected int |
kreach
Number of neighbors used for reachability distance.
|
protected int |
krefer
Number of neighbors in comparison set.
|
private static Logging |
LOG
The logger for this class.
|
private static boolean |
objectIsInKNN
Include object itself in kNN neighborhood.
|
protected DistanceFunction<? super O,D> |
reachabilityDistanceFunction
Reachability distance function.
|
protected DistanceFunction<? super O,D> |
referenceDistanceFunction
Neighborhood distance function.
|
| Constructor and Description |
|---|
FlexibleLOF(int krefer,
int kreach,
DistanceFunction<? super O,D> neighborhoodDistanceFunction,
DistanceFunction<? super O,D> reachabilityDistanceFunction)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected Pair<WritableDoubleDataStore,DoubleMinMax> |
computeLOFs(DBIDs ids,
DoubleDataStore lrds,
KNNQuery<O,D> knnRefer)
Computes the Local outlier factor (LOF) of the specified objects.
|
protected WritableDoubleDataStore |
computeLRDs(DBIDs ids,
KNNQuery<O,D> knnReach)
Computes the local reachability density (LRD) of the specified objects.
|
protected FlexibleLOF.LOFResult<O,D> |
doRunInTime(DBIDs ids,
KNNQuery<O,D> kNNRefer,
KNNQuery<O,D> kNNReach,
StepProgress stepprog)
Performs the Generalized LOF_SCORE algorithm on the given database and
returns a
FlexibleLOF.LOFResult encapsulating information that may
be needed by an OnlineLOF algorithm. |
TypeInformation[] |
getInputTypeRestriction()
Get the input type restriction used for negotiating the data query.
|
private Pair<KNNQuery<O,D>,KNNQuery<O,D>> |
getKNNQueries(Database database,
Relation<O> relation,
StepProgress stepprog)
Get the kNN queries for the algorithm.
|
protected Logging |
getLogger()
Get the (STATIC) logger for this class.
|
OutlierResult |
run(Database database,
Relation<O> relation)
Performs the Generalized LOF algorithm on the given database by calling
doRunInTime(de.lmu.ifi.dbs.elki.database.ids.DBIDs, de.lmu.ifi.dbs.elki.database.query.knn.KNNQuery<O, D>, de.lmu.ifi.dbs.elki.database.query.knn.KNNQuery<O, D>, de.lmu.ifi.dbs.elki.logging.progress.StepProgress). |
makeParameterDistanceFunction, runclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitrunprivate static final Logging LOG
protected int krefer
protected int kreach
protected DistanceFunction<? super O,D extends NumberDistance<D,?>> referenceDistanceFunction
protected DistanceFunction<? super O,D extends NumberDistance<D,?>> reachabilityDistanceFunction
private static boolean objectIsInKNN
public FlexibleLOF(int krefer,
int kreach,
DistanceFunction<? super O,D> neighborhoodDistanceFunction,
DistanceFunction<? super O,D> reachabilityDistanceFunction)
krefer - The number of neighbors for referencekreach - The number of neighbors for reachability distanceneighborhoodDistanceFunction - the neighborhood distance functionreachabilityDistanceFunction - the reachability distance functionpublic OutlierResult run(Database database, Relation<O> relation)
doRunInTime(de.lmu.ifi.dbs.elki.database.ids.DBIDs, de.lmu.ifi.dbs.elki.database.query.knn.KNNQuery<O, D>, de.lmu.ifi.dbs.elki.database.query.knn.KNNQuery<O, D>, de.lmu.ifi.dbs.elki.logging.progress.StepProgress).database - Database to queryrelation - Data to processprivate Pair<KNNQuery<O,D>,KNNQuery<O,D>> getKNNQueries(Database database, Relation<O> relation, StepProgress stepprog)
relation - the datastepprog - the progress loggerprotected FlexibleLOF.LOFResult<O,D> doRunInTime(DBIDs ids, KNNQuery<O,D> kNNRefer, KNNQuery<O,D> kNNReach, StepProgress stepprog)
FlexibleLOF.LOFResult encapsulating information that may
be needed by an OnlineLOF algorithm.ids - Object idskNNRefer - the kNN query w.r.t. reference neighborhood distance
functionkNNReach - the kNN query w.r.t. reachability distance functionstepprog - Progress loggerprotected WritableDoubleDataStore computeLRDs(DBIDs ids, KNNQuery<O,D> knnReach)
ids - the ids of the objectsknnReach - the precomputed neighborhood of the objects w.r.t. the
reachability distanceprotected Pair<WritableDoubleDataStore,DoubleMinMax> computeLOFs(DBIDs ids, DoubleDataStore lrds, KNNQuery<O,D> knnRefer)
ids - the ids of the objectslrds - the LRDs of the objectsknnRefer - the precomputed neighborhood of the objects w.r.t. the
reference distancepublic TypeInformation[] getInputTypeRestriction()
AbstractAlgorithmgetInputTypeRestriction in interface AlgorithmgetInputTypeRestriction in class AbstractAlgorithm<OutlierResult>protected Logging getLogger()
AbstractAlgorithmgetLogger in class AbstractAlgorithm<OutlierResult>