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

Class DANN

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


    public class DANN
    extends java.lang.Object
    implements Classifier, Parameterized
    DANN is an implementation of Discriminant Adaptive Nearest Neighbor. DANN has a fixed O(n) classification time. At each classification, DANN uses a large set of points to iteratively create and adjust a distance metic that reflects the separability of classes at a localized level. This increases the work considerably over a normal NearestNeighbour classifier. The localized metric is similar to the MahalanobisDistance
    Because DANN builds its own metric, it is not possible to provide one. The VectorCollectionFactory allowed in the constructor is to accelerate the first convergence step. In homogeneous areas of the data set, queries can be answered in O(log n) if the vector collection supports it.

    See: Hastie, T.,&Tibshirani, R. (1996). Discriminant adaptive nearest neighbor classification. IEEE Transactions on Pattern Analysis and Machine Intelligence, 18(6), 607–616. doi:10.1109/34.506411
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static double DEFAULT_EPS
      The default regularization used when building a metric is 1.0
      static int DEFAULT_ITERATIONS
      The default number of iterations for creating the metric is 1
      static int DEFAULT_K
      The default number of neighbors to use when classifying is 1
      static int DEFAULT_KN
      The default number of neighbors to use when building a metric is 40.
    • Constructor Summary

      Constructors 
      Constructor and Description
      DANN()
      Creates a new DANN classifier
      DANN(int kn, int k)
      Creates a new DANN classifier
      DANN(int kn, int k, double eps)
      Creates a new DANN classifier
      DANN(int kn, int k, double eps, int maxIterations, VectorCollection<VecPaired<Vec,java.lang.Integer>> vcf)
      Creates a new DANN classifier
      DANN(int kn, int k, double eps, VectorCollection<VecPaired<Vec,java.lang.Integer>> vcf)
      Creates a new DANN classifier
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      CategoricalResults classify(DataPoint data)
      Performs classification on the given data point.
      Classifier clone() 
      double getEpsilon()
      Returns the regularization parameter that is applied to the diagonal of the matrix when creating each new metric.
      int getK()
      Returns the number of nearest neighbors to use when predicting
      int getKn()
      Returns the number of nearest neighbors to use when adapting the distance metric
      int getMaxIterations()
      Returns the number of times the distance metric will be updated.
      static Distribution guessK(DataSet d)
      Guesses the distribution to use for the number of neighbors to consider
      static Distribution guessKn(DataSet d)
      Guesses the distribution to use for the number of neighbors to consider
      void setEpsilon(double eps)
      Sets the regularization to apply the the diagonal of the scatter matrix when creating each new metric.
      void setK(int k)
      Sets the number of nearest neighbors to use when predicting
      void setKn(int kn)
      Sets the number of nearest neighbors to use when adapting the distance metric.
      void setMaxIterations(int maxIterations)
      Sets the number of times a new distance metric will be created for each query.
      boolean supportsWeightedData()
      Indicates whether the model knows how to train using weighted data points.
      void train(ClassificationDataSet dataSet, boolean parallel)
      Trains the classifier and constructs a model for classification using the given data set.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_KN

        public static final int DEFAULT_KN
        The default number of neighbors to use when building a metric is 40.
        See Also:
        Constant Field Values
      • DEFAULT_K

        public static final int DEFAULT_K
        The default number of neighbors to use when classifying is 1
        See Also:
        Constant Field Values
      • DEFAULT_EPS

        public static final double DEFAULT_EPS
        The default regularization used when building a metric is 1.0
        See Also:
        Constant Field Values
      • DEFAULT_ITERATIONS

        public static final int DEFAULT_ITERATIONS
        The default number of iterations for creating the metric is 1
        See Also:
        Constant Field Values
    • Constructor Detail

      • DANN

        public DANN()
        Creates a new DANN classifier
      • DANN

        public DANN(int kn,
                    int k)
        Creates a new DANN classifier
        Parameters:
        kn - the number of neighbors to use in casting a net to build a new metric
        k - the number of neighbors to use with the final metric in classification
      • DANN

        public DANN(int kn,
                    int k,
                    double eps)
        Creates a new DANN classifier
        Parameters:
        kn - the number of neighbors to use in casting a net to build a new metric
        k - the number of neighbors to use with the final metric in classification
        eps - the regularization to add to the metric creation
      • DANN

        public DANN(int kn,
                    int k,
                    double eps,
                    VectorCollection<VecPaired<Vec,java.lang.Integer>> vcf)
        Creates a new DANN classifier
        Parameters:
        kn - the number of neighbors to use in casting a net to build a new metric
        k - the number of neighbors to use with the final metric in classification
        eps - the regularization to add to the metric creation
        vcf - the default vector collection that will be used for initial neighbor search
      • DANN

        public DANN(int kn,
                    int k,
                    double eps,
                    int maxIterations,
                    VectorCollection<VecPaired<Vec,java.lang.Integer>> vcf)
        Creates a new DANN classifier
        Parameters:
        kn - the number of neighbors to use in casting a net to build a new metric
        k - the number of neighbors to use with the final metric in classification
        eps - the regularization to add to the metric creation
        maxIterations - the maximum number of times to adjust the metric for each classification
        vcf - the default vector collection that will be used for initial neighbor search
    • Method Detail

      • setK

        public void setK(int k)
        Sets the number of nearest neighbors to use when predicting
        Parameters:
        k - the number of neighbors
      • getK

        public int getK()
        Returns the number of nearest neighbors to use when predicting
        Returns:
        the number of neighbors used for classification
      • setKn

        public void setKn(int kn)
        Sets the number of nearest neighbors to use when adapting the distance metric. At each iteration of the algorithm, a new distance metric will be created. A larger number of neighbors is used to create a net of points, around which the metric will be adapted.
        Parameters:
        kn - the number of neighbors to use
      • getKn

        public int getKn()
        Returns the number of nearest neighbors to use when adapting the distance metric
        Returns:
        the number of neighbors used to adapt the metric
      • setMaxIterations

        public void setMaxIterations(int maxIterations)
        Sets the number of times a new distance metric will be created for each query. The metric should converge quickly. For this reason, and do to a lack of performance difference, it is highly recommended to use the default of 1 iteration.
        Parameters:
        maxIterations - the maximum number of times the metric will be updated
      • getMaxIterations

        public int getMaxIterations()
        Returns the number of times the distance metric will be updated.
        Returns:
        the number of iterations the metric will be updated
      • setEpsilon

        public void setEpsilon(double eps)
        Sets the regularization to apply the the diagonal of the scatter matrix when creating each new metric.
        Parameters:
        eps - the regularization value
      • getEpsilon

        public double getEpsilon()
        Returns the regularization parameter that is applied to the diagonal of the matrix when creating each new metric.
        Returns:
        the regularization used.
      • 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.
      • 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
        Returns:
        true if the model supports weighted data, false otherwise
      • clone

        public Classifier clone()
        Specified by:
        clone in interface Classifier
        Overrides:
        clone in class java.lang.Object
      • guessK

        public static Distribution guessK(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 K parameter
      • guessKn

        public static Distribution guessKn(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 Kn parameter

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.