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 LOF<O,D extends NumberDistance<D,?>> extends AbstractAlgorithm<OutlierResult> implements OutlierAlgorithm
Algorithm to compute density-based local outlier factors in a database based
on a specified parameter K_ID
(-lof.k
).
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
AbstractDistanceBasedAlgorithm.DISTANCE_FUNCTION_ID
, while the reference set used in reachability distance computation is
configured using REACHABILITY_DISTANCE_FUNCTION_ID
.
The original LOF parameter was called "minPts". Since kNN queries
in ELKI have slightly different semantics - exactly k neighbors are returned
- we chose to rename the parameter to K_ID
(-lof.k
) to
reflect this difference.
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 |
LOF.LOFResult<O,D extends NumberDistance<D,?>>
Encapsulates information like the neighborhood, the LRD and LOF values of
the objects during a run of the
LOF algorithm. |
static class |
LOF.Parameterizer<O,D extends NumberDistance<D,?>>
Parameterization class.
|
Modifier and Type | Field and Description |
---|---|
protected int |
k
Holds the value of
K_ID . |
static OptionID |
K_ID
Parameter to specify the number of nearest neighbors of an object to be
considered for computing its LOF_SCORE, must be an integer greater than 1.
|
private static Logging |
logger
The logger for this class.
|
protected DistanceFunction<? super O,D> |
neighborhoodDistanceFunction
Neighborhood distance function.
|
private static boolean |
objectIsInKNN
Include object itself in kNN neighborhood.
|
static OptionID |
REACHABILITY_DISTANCE_FUNCTION_ID
The distance function to determine the reachability distance between
database objects.
|
protected DistanceFunction<? super O,D> |
reachabilityDistanceFunction
Reachability distance function.
|
Constructor and Description |
---|
LOF(int k,
DistanceFunction<? super O,D> neighborhoodDistanceFunction,
DistanceFunction<? super O,D> reachabilityDistanceFunction)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected Pair<WritableDataStore<Double>,DoubleMinMax> |
computeLOFs(DBIDs ids,
DataStore<Double> lrds,
KNNQuery<O,D> knnRefer)
Computes the Local outlier factor (LOF) of the specified objects.
|
protected WritableDataStore<Double> |
computeLRDs(DBIDs ids,
KNNQuery<O,D> knnReach)
Computes the local reachability density (LRD) of the specified objects.
|
protected LOF.LOFResult<O,D> |
doRunInTime(KNNQuery<O,D> kNNRefer,
KNNQuery<O,D> kNNReach,
StepProgress stepprog)
Performs the Generalized LOF_SCORE algorithm on the given database and
returns a
LOF.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(Relation<O> relation,
StepProgress stepprog)
Get the kNN queries for the algorithm.
|
protected Logging |
getLogger()
Get the (STATIC) logger for this class.
|
OutlierResult |
run(Relation<O> relation)
Performs the Generalized LOF_SCORE algorithm on the given database by
calling
#doRunInTime(Database) . |
makeParameterDistanceFunction, run
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
run
private static final Logging logger
public static final OptionID REACHABILITY_DISTANCE_FUNCTION_ID
public static final OptionID K_ID
protected int k
K_ID
.protected DistanceFunction<? super O,D extends NumberDistance<D,?>> neighborhoodDistanceFunction
protected DistanceFunction<? super O,D extends NumberDistance<D,?>> reachabilityDistanceFunction
private static boolean objectIsInKNN
public LOF(int k, DistanceFunction<? super O,D> neighborhoodDistanceFunction, DistanceFunction<? super O,D> reachabilityDistanceFunction)
k
- the value of kneighborhoodDistanceFunction
- the neighborhood distance functionreachabilityDistanceFunction
- the reachability distance functionpublic OutlierResult run(Relation<O> relation)
#doRunInTime(Database)
.relation
- Data to processprivate Pair<KNNQuery<O,D>,KNNQuery<O,D>> getKNNQueries(Relation<O> relation, StepProgress stepprog)
relation
- the datastepprog
- the progress loggerprotected LOF.LOFResult<O,D> doRunInTime(KNNQuery<O,D> kNNRefer, KNNQuery<O,D> kNNReach, StepProgress stepprog) throws IllegalStateException
LOF.LOFResult
encapsulating information that may be
needed by an OnlineLOF algorithm.kNNRefer
- the kNN query w.r.t. reference neighborhood distance
functionkNNReach
- the kNN query w.r.t. reachability distance functionIllegalStateException
protected WritableDataStore<Double> 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<WritableDataStore<Double>,DoubleMinMax> computeLOFs(DBIDs ids, DataStore<Double> 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()
AbstractAlgorithm
getInputTypeRestriction
in interface Algorithm
getInputTypeRestriction
in class AbstractAlgorithm<OutlierResult>
protected Logging getLogger()
AbstractAlgorithm
getLogger
in class AbstractAlgorithm<OutlierResult>