Class AveragePrecisionAtK<O>

  • Type Parameters:
    O - Object type
    All Implemented Interfaces:
    Algorithm

    public class AveragePrecisionAtK<O>
    extends java.lang.Object
    implements Algorithm
    Evaluate a distance functions performance by computing the average precision at k, when ranking the objects by distance.
    Since:
    0.5.0
    Author:
    Erich Schubert
    • Field Detail

      • LOG

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

        private Distance<? super O> distance
        Distance function used.
      • k

        private int k
        The parameter k - the number of neighbors to retrieve.
      • sampling

        private double sampling
        Relative number of object to use in sampling.
      • includeSelf

        private boolean includeSelf
        Include query object in evaluation.
    • Constructor Detail

      • AveragePrecisionAtK

        public AveragePrecisionAtK​(Distance<? super O> distance,
                                   int k,
                                   double sampling,
                                   RandomFactory random,
                                   boolean includeSelf)
        Constructor.
        Parameters:
        distance - Distance function
        k - K parameter
        sampling - Sampling rate
        random - Random sampling generator
        includeSelf - Include query object in evaluation
    • 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 CollectionResult<double[]> run​(Relation<O> relation,
                                              Relation<?> lrelation)
        Run the algorithm
        Parameters:
        relation - Relation for distance computations
        lrelation - Relation for class label comparison
        Returns:
        Vectors containing mean and standard deviation.
      • match

        protected static boolean match​(java.lang.Object ref,
                                       java.lang.Object test)
        Test whether two relation agree.
        Parameters:
        ref - Reference object
        test - Test object
        Returns:
        true if the objects match