Class KNNOutlier<O>

  • Type Parameters:
    O - the type of objects handled by this algorithm
    All Implemented Interfaces:
    Algorithm, OutlierAlgorithm

    @Title("KNN outlier: Efficient Algorithms for Mining Outliers from Large Data Sets")
    @Description("Outlier Detection based on the distance of an object to its k nearest neighbor.")
    @Reference(authors="S. Ramaswamy, R. Rastogi, K. Shim",
               title="Efficient Algorithms for Mining Outliers from Large Data Sets",
               booktitle="Proc. Int. Conf. on Management of Data (SIGMOD 2000)",
               url="https://doi.org/10.1145/342009.335437",
               bibkey="DBLP:conf/sigmod/RamaswamyRS00")
    @Alias("knno")
    @Priority(200)
    public class KNNOutlier<O>
    extends java.lang.Object
    implements OutlierAlgorithm
    Outlier Detection based on the distance of an object to its k nearest neighbor.

    This implementation differs from the original pseudocode: the k nearest neighbors do not exclude the point that is currently evaluated. I.e. for k=1 the resulting score is the distance to the 1-nearest neighbor that is not the query point and therefore should match k=2 in the exact pseudocode - a value of k=1 in the original code does not make sense, as the 1NN distance will be 0 for every point in the database. If you for any reason want to use the original algorithm, subtract 1 from the k parameter.

    Reference:

    S. Ramaswamy, R. Rastogi, K. Shim
    Efficient Algorithms for Mining Outliers from Large Data Sets.
    In: Proc. Int. Conf. on Management of Data (SIGMOD 2000)

    Since:
    0.3
    Author:
    Lisa Reichert
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  KNNOutlier.Par<O>
      Parameterization class.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected Distance<? super O> distance
      Distance function used.
      protected int kplus
      The parameter k (plus query point!)
      private static Logging LOG
      The logger for this class.
    • Constructor Summary

      Constructors 
      Constructor Description
      KNNOutlier​(Distance<? super O> distance, int k)
      Constructor for a single kNN query.
    • Field Detail

      • LOG

        private static final Logging LOG
        The logger for this class.
      • distance

        protected Distance<? super O> distance
        Distance function used.
      • kplus

        protected int kplus
        The parameter k (plus query point!)
    • Constructor Detail

      • KNNOutlier

        public KNNOutlier​(Distance<? super O> distance,
                          int k)
        Constructor for a single kNN query.
        Parameters:
        distance - distance function to use
        k - Value of k (excluding query point!)
    • Method Detail

      • getInputTypeRestriction

        public TypeInformation[] getInputTypeRestriction()
        Description copied from interface: Algorithm
        Get the input type restriction used for negotiating the data query.
        Specified by:
        getInputTypeRestriction in interface Algorithm
        Returns:
        Type restriction
      • run

        public OutlierResult run​(Relation<O> relation)
        Runs the algorithm in the timed evaluation part.
        Parameters:
        relation - Data relation