Class KNNTrainer<T extends Output<T>>

java.lang.Object
org.tribuo.common.nearest.KNNTrainer<T>
All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.config.Configurable, com.oracle.labs.mlrg.olcut.provenance.Provenancable<TrainerProvenance>, Trainer<T>

public class KNNTrainer<T extends Output<T>> extends Object implements Trainer<T>
A Trainer for k-nearest neighbour models.
  • Constructor Details

    • KNNTrainer

      public KNNTrainer(int k, Distance dist, int numThreads, EnsembleCombiner<T> combiner, KNNModel.Backend backend, NeighboursQueryFactoryType nqFactoryType)
      Creates a K-NN trainer using the supplied parameters.
      Parameters:
      k - The number of nearest neighbours to consider.
      dist - The distance function.
      numThreads - The number of threads to use.
      combiner - The combination function to aggregate the k predictions.
      backend - The computational backend.
      nqFactoryType - The nearest neighbour implementation factory to use.
    • KNNTrainer

      @Deprecated public KNNTrainer(int k, KNNTrainer.Distance distance, int numThreads, EnsembleCombiner<T> combiner, KNNModel.Backend backend)
      Deprecated.
      This Constructor is deprecated in version 4.3.
      Creates a K-NN trainer using the supplied parameters. neighboursQueryFactory defaults to NeighboursBruteForceFactory.
      Parameters:
      k - The number of nearest neighbours to consider.
      distance - The distance function.
      numThreads - The number of threads to use.
      combiner - The combination function to aggregate the k predictions.
      backend - The computational backend.
    • KNNTrainer

      public KNNTrainer(int k, int numThreads, EnsembleCombiner<T> combiner, KNNModel.Backend backend, NeighboursQueryFactory neighboursQueryFactory)
      Creates a K-NN trainer using the supplied parameters.
      Parameters:
      k - The number of nearest neighbours to consider.
      numThreads - The number of threads to use.
      combiner - The combination function to aggregate the k predictions.
      backend - The computational backend.
      neighboursQueryFactory - The nearest neighbour implementation factory to use.
  • Method Details