Class KNNBenchmark<O>

  • Type Parameters:
    O - Object type

    public class KNNBenchmark<O>
    extends AbstractDistanceBasedApplication<O>
    Benchmarking experiment that computes the k nearest neighbors for each query point. The query points can either come from a separate data source, or from the original database.
    Since:
    0.5.5
    Author:
    Erich Schubert
    • Field Detail

      • LOG

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

        protected int k
        Number of neighbors to retrieve.
      • queries

        protected DatabaseConnection queries
        The alternate query point source. Optional.
      • sampling

        protected double sampling
        Sampling size.
      • random

        protected RandomFactory random
        Random generator factory
    • Constructor Detail

      • KNNBenchmark

        public KNNBenchmark​(InputStep inputstep,
                            Distance<? super O> distance,
                            int k,
                            DatabaseConnection queries,
                            double sampling,
                            RandomFactory random)
        Constructor.
        Parameters:
        inputstep - Input step
        distance - Distance function to use
        k - K parameter
        queries - Query data set (may be null!)
        sampling - Sampling rate
        random - Random factory
    • Method Detail

      • logIndexStatistics

        private void logIndexStatistics​(Database database)
        Log index statistics before and after querying.
        Parameters:
        database - Database
      • run

        private int run​(KNNSearcher<DBIDRef> knnQuery,
                        Relation<O> relation,
                        Duration dur,
                        MeanVariance mv,
                        MeanVariance mvdist)
        Run with the database as query source
        Parameters:
        knnQuery - Query object
        relation - Input data
        dur - Duration
        mv - statistics collector
        mvdist - statistics collector
        Returns:
        hash code of the results
      • run

        private int run​(KNNSearcher<O> knnQuery,
                        Duration dur,
                        MeanVariance mv,
                        MeanVariance mvdist)
        Run using a second database as query source
        Parameters:
        knnQuery - Query object
        dur - Duration
        mv - statistics collector
        mvdist - statistics collector
        Returns:
        hash code of the results
      • main

        public static void main​(java.lang.String[] args)
        Runs the benchmark
        Parameters:
        args - parameter list according to description