Documentation of 'Catalano.MachineLearning.Classification.KNearestNeighbors' Java class
KNearestNeighbors
Catalano.MachineLearning.Classification

Class KNearestNeighbors

  • All Implemented Interfaces:
    IClassifier, java.io.Serializable, java.lang.Cloneable


    public class KNearestNeighbors
    extends java.lang.Object
    implements IClassifier, java.io.Serializable
    K Nearest Neighbour classifier.
    See Also:
    Serialized Form
    • Constructor Detail

      • KNearestNeighbors

        public KNearestNeighbors()
        Initializes a new instance of the KNearestNeighbors class.
      • KNearestNeighbors

        public KNearestNeighbors(int k)
        Initializes a new instance of the KNearestNeighbors class.
        Parameters:
        k - Number of neighbors.
      • KNearestNeighbors

        public KNearestNeighbors(int k,
                                 IDivergence divergence)
        Initializes a new instance of the KNearestNeighbors class.
        Parameters:
        k - Number of neighbors.
        divergence - Distance.
      • KNearestNeighbors

        public KNearestNeighbors(int k,
                                 IMercerKernel kernel)
        Initializes a new instance of the KNearestNeighbors class.
        Parameters:
        k - Number of neighbors.
        kernel - Kernel.
    • Method Detail

      • getK

        public int getK()
        Get number of neighbours.
        Returns:
        Number of neighbours.
      • setK

        public void setK(int k)
        Set number of neighbours.
        Parameters:
        k - Number of neighbours.
      • getKernel

        public IMercerKernel getKernel()
        Get the kernel metric.
        Returns:
        Kernel.
      • setMercerKernel

        public void setMercerKernel(IMercerKernel kernel)
        Set the kernel metric.
        Parameters:
        kernel - Kernel.
      • getDistance

        public IDivergence getDistance()
        Get the divergence function.
        Returns:
        Divergence.
      • setDistance

        public void setDistance(IDivergence divergence)
        Set the divergence function.
        Parameters:
        divergence - Divergence.
      • Learn

        public void Learn(double[][] input,
                          int[] output)
        Description copied from interface: IClassifier
        Learn.
        Specified by:
        Learn in interface IClassifier
        Parameters:
        input - Matrix of features.
        output - Labels.
      • Predict

        public int Predict(double[] feature)
        Compute.
        Specified by:
        Predict in interface IClassifier
        Parameters:
        feature - Feature to compute.
        Returns:
        Object.
      • clone

        public IClassifier clone()
        Description copied from interface: IClassifier
        Clone of the object.
        Specified by:
        clone in interface IClassifier
        Overrides:
        clone in class java.lang.Object
        Returns:
        A new copy of the object.

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.