Class FlexibleLOF<O>

  • Type Parameters:
    O - the type of objects handled by this algorithm
    All Implemented Interfaces:
    elki.Algorithm, OutlierAlgorithm
    Direct Known Subclasses:
    OnlineLOF

    @Title("FlexibleLOF: Local Outlier Factor with additional options")
    @Description("Algorithm to compute density-based local outlier factors in a database based on the neighborhood size parameter \'k\'")
    @Reference(authors="Markus M. Breunig, Hans-Peter Kriegel, Raymond Ng, J\u00f6rg Sander",
               title="LOF: Identifying Density-Based Local Outliers",
               booktitle="Proc. 2nd ACM SIGMOD Int. Conf. on Management of Data (SIGMOD\'00)",
               url="https://doi.org/10.1145/342009.335388",
               bibkey="DBLP:conf/sigmod/BreunigKNS00")
    public class FlexibleLOF<O>
    extends java.lang.Object
    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 standard distance function, while the reference set used in reachability distance computation is configured using a separate reachability distance function.

    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 -lof.krefer and -lof.kreach.

    Reference:
    Markus M. Breunig, Hans-Peter Kriegel, Raymond Ng, Jörg Sander
    LOF: Identifying Density-Based Local Outliers
    Proc. 2nd ACM SIGMOD Int. Conf. on Management of Data (SIGMOD'00)

    Since:
    0.2
    Author:
    Peer Kröger, Erich Schubert, Elke Achtert
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  FlexibleLOF.LOFResult<O>
      Encapsulates information like the neighborhood, the LRD and LOF values of the objects during a run of the FlexibleLOF algorithm.
      static class  FlexibleLOF.Par<O>
      Parameterization class.
      • Nested classes/interfaces inherited from interface elki.Algorithm

        elki.Algorithm.Utils
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int kreach
      Number of neighbors used for reachability distance.
      protected int krefer
      Number of neighbors in comparison set.
      private static elki.logging.Logging LOG
      The logger for this class.
      protected elki.distance.Distance<? super O> reachabilityDistance
      Reachability distance function.
      protected elki.distance.Distance<? super O> referenceDistance
      Neighborhood distance function.
    • Constructor Summary

      Constructors 
      Constructor Description
      FlexibleLOF​(int krefer, int kreach, elki.distance.Distance<? super O> neighborhoodDistance, elki.distance.Distance<? super O> reachabilityDistance)
      Constructor.
    • Field Detail

      • LOG

        private static final elki.logging.Logging LOG
        The logger for this class.
      • krefer

        protected int krefer
        Number of neighbors in comparison set.
      • kreach

        protected int kreach
        Number of neighbors used for reachability distance.
      • referenceDistance

        protected elki.distance.Distance<? super O> referenceDistance
        Neighborhood distance function.
      • reachabilityDistance

        protected elki.distance.Distance<? super O> reachabilityDistance
        Reachability distance function.
    • Constructor Detail

      • FlexibleLOF

        public FlexibleLOF​(int krefer,
                           int kreach,
                           elki.distance.Distance<? super O> neighborhoodDistance,
                           elki.distance.Distance<? super O> reachabilityDistance)
        Constructor.
        Parameters:
        krefer - The number of neighbors for reference
        kreach - The number of neighbors for reachability distance
        neighborhoodDistance - the neighborhood distance function
        reachabilityDistance - the reachability distance function
    • Method Detail

      • getInputTypeRestriction

        public elki.data.type.TypeInformation[] getInputTypeRestriction()
        Specified by:
        getInputTypeRestriction in interface elki.Algorithm
      • doRunInTime

        protected FlexibleLOF.LOFResult<O> doRunInTime​(elki.database.ids.DBIDs ids,
                                                       elki.database.query.knn.KNNSearcher<elki.database.ids.DBIDRef> kNNRefer,
                                                       elki.database.query.knn.KNNSearcher<elki.database.ids.DBIDRef> kNNReach,
                                                       elki.logging.progress.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.
        Parameters:
        ids - Object ids
        kNNRefer - the kNN query w.r.t. reference neighborhood distance function
        kNNReach - the kNN query w.r.t. reachability distance function
        stepprog - Progress logger
        Returns:
        LOF result
      • computeLRDs

        protected void computeLRDs​(elki.database.query.knn.KNNSearcher<elki.database.ids.DBIDRef> knnq,
                                   elki.database.ids.DBIDs ids,
                                   elki.database.datastore.WritableDoubleDataStore lrds)
        Computes the local reachability density (LRD) of the specified objects.
        Parameters:
        knnq - the precomputed neighborhood of the objects w.r.t. the reachability distance
        ids - the ids of the objects
        lrds - Reachability storage
      • computeLOFs

        protected void computeLOFs​(elki.database.query.knn.KNNSearcher<elki.database.ids.DBIDRef> knnq,
                                   elki.database.ids.DBIDs ids,
                                   elki.database.datastore.DoubleDataStore lrds,
                                   elki.database.datastore.WritableDoubleDataStore lofs,
                                   elki.math.DoubleMinMax lofminmax)
        Computes the Local outlier factor (LOF) of the specified objects.
        Parameters:
        knnq - the precomputed neighborhood of the objects w.r.t. the reference distance
        ids - IDs to process
        lrds - Local reachability distances
        lofs - Local outlier factor storage
        lofminmax - Score minimum/maximum tracker