Documentation of 'jsat.classifiers.knn.NearestNeighbour' Java class
NearestNeighbour
jsat.classifiers.knn

Class NearestNeighbour

    • Constructor Detail

      • NearestNeighbour

        public NearestNeighbour(int k)
        Constructs a new Nearest Neighbor Classifier
        Parameters:
        k - the number of neighbors to use
      • NearestNeighbour

        public NearestNeighbour(int k,
                                VectorCollection<VecPaired<Vec,java.lang.Double>> vcf)
        Constructs a new Nearest Neighbor Classifier
        Parameters:
        k - the number of neighbors to use
        vcf - the vector collection factory to use for storing and querying
      • NearestNeighbour

        public NearestNeighbour(int k,
                                boolean weighted)
        Constructs a new Nearest Neighbor Classifier
        Parameters:
        k - the number of neighbors to use
        weighted - whether or not to weight the influence of neighbors by their distance
      • NearestNeighbour

        public NearestNeighbour(int k,
                                boolean weighted,
                                DistanceMetric distanceMetric)
        Constructs a new Nearest Neighbor Classifier
        Parameters:
        k - the number of neighbors to use
        weighted - whether or not to weight the influence of neighbors by their distance
        distanceMetric - the method of computing distance between two vectors.
      • NearestNeighbour

        public NearestNeighbour(int k,
                                boolean weighted,
                                DistanceMetric distanceMetric,
                                VectorCollection<VecPaired<Vec,java.lang.Double>> vcf)
        Constructs a new Nearest Neighbor Classifier
        Parameters:
        k - the number of neighbors to use
        weighted - whether or not to weight the influence of neighbors by their distance
        distanceMetric - the method of computing distance between two vectors.
        vcf - the vector collection factory to use for storing and querying
    • Method Detail

      • getNeighbors

        public int getNeighbors()
        Returns the number of neighbors currently consulted to make decisions
        Returns:
        the number of neighbors
      • setNeighbors

        public void setNeighbors(int k)
        Sets the number of neighbors to consult when making decisions
        Parameters:
        k - the number of neighbors to use
      • getNeighbors

        public int getNeighbors(int k)
      • setDistanceMetric

        public void setDistanceMetric(DistanceMetric distanceMetric)
      • classify

        public CategoricalResults classify(DataPoint data)
        Description copied from interface: Classifier
        Performs classification on the given data point.
        Specified by:
        classify in interface Classifier
        Parameters:
        data - the data point to classify
        Returns:
        the results of the classification.
      • train

        public void train(ClassificationDataSet dataSet,
                          boolean parallel)
        Description copied from interface: Classifier
        Trains the classifier and constructs a model for classification using the given data set. If the training method knows how, it will used the threadPool to conduct training in parallel. This method will block until the training has completed.
        Specified by:
        train in interface Classifier
        Parameters:
        dataSet - the data set to train on
        parallel - true if multiple threads should be used to train the model. false if it should be done in a single threaded manner.
      • guessNeighbors

        public static Distribution guessNeighbors(DataSet d)
        Guesses the distribution to use for the number of neighbors to consider
        Parameters:
        d - the dataset to get the guess for
        Returns:
        the guess for the Neighbors parameter
      • supportsWeightedData

        public boolean supportsWeightedData()
        Description copied from interface: Classifier
        Indicates whether the model knows how to train using weighted data points. If it does, the model will train assuming the weights. The values returned by this method may change depending on the parameters set for the model.
        Specified by:
        supportsWeightedData in interface Classifier
        Specified by:
        supportsWeightedData in interface Regressor
        Returns:
        true if the model supports weighted data, false otherwise

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.