Documentation of 'jsat.classifiers.neuralnetwork.LVQ' Java class
LVQ
jsat.classifiers.neuralnetwork

Class LVQ

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, Classifier, Parameterized
    Direct Known Subclasses:
    LVQLLC


    public class LVQ
    extends java.lang.Object
    implements Classifier, Parameterized
    Learning Vector Quantization (LVQ) is an algorithm that extends SOM to take advantage of label information to perform classification. It creates a number of representatives, or learning vectors, for each class. The LVs are then updated iteratively to push away from the wrong class and pull closer to the correct class. LVQ is equivalent to a type of 2 layer neural network.
    See Also:
    Serialized Form
    • Field Detail

      • DEFAULT_ITERATIONS

        public static final int DEFAULT_ITERATIONS
        The default number of iterations is 200
        See Also:
        Constant Field Values
      • DEFAULT_LEARNING_RATE

        public static final double DEFAULT_LEARNING_RATE
        The default learning rate 0.1
        See Also:
        Constant Field Values
      • DEFAULT_EPS

        public static final double DEFAULT_EPS
        The default eps distance factor between the two wining vectors 0.3
        See Also:
        Constant Field Values
      • DEFAULT_LVQ_METHOD

        public static final LVQ.LVQVersion DEFAULT_LVQ_METHOD
        The default method of LVQ to use LVQ3
      • DEFAULT_REPS_PER_CLASS

        public static final int DEFAULT_REPS_PER_CLASS
        The default number of representatives per class is 3
        See Also:
        Constant Field Values
      • DEFAULT_STOPPING_DIST

        public static final double DEFAULT_STOPPING_DIST
        The default stopping distance for convergence is 0.001
        See Also:
        Constant Field Values
    • Constructor Detail

      • LVQ

        public LVQ(DistanceMetric dm,
                   int iterations)
        Creates a new LVQ instance
        Parameters:
        dm - the distance metric to use
        iterations - the number of iterations to perform
      • LVQ

        public LVQ(DistanceMetric dm,
                   int iterations,
                   double learningRate,
                   int representativesPerClass)
        Creates a new LVQ instance
        Parameters:
        dm - the distance metric to use
        iterations - the number of iterations to perform
        learningRate - the learning rate to use when updating
        representativesPerClass - the number of representatives to create for each class
      • LVQ

        public LVQ(DistanceMetric dm,
                   int iterations,
                   double learningRate,
                   int representativesPerClass,
                   LVQ.LVQVersion lvqVersion,
                   DecayRate learningDecay)
        Creates a new LVQ instance
        Parameters:
        dm - the distance metric to use
        iterations - the number of iterations to perform
        learningRate - the learning rate to use when updating
        representativesPerClass - the number of representatives to create for each class
        lvqVersion - the version of LVQ to use
        learningDecay - the amount of decay to apply to the learning rate
    • Method Detail

      • setMScale

        public void setMScale(double mScale)
        When using LVQ.LVQVersion.LVQ3, a 3rd case exists where up to two learning vectors can be updated at the same time if they have the same class. To avoid over fitting, an additional regularizing weight is placed upon the learning rate for their update. THis sets the additional multiplied. It is suggested to use a value in the range of [0.1, 0.5]
        Parameters:
        mScale - the multiplication factor to apply to the learning vectors
      • getMScale

        public double getMScale()
        Returns the scale used for the LVQ 3 learning algorithm update set.
        Returns:
        a scale used during LVQ3
      • setEpsilonDistance

        public void setEpsilonDistance(double eps)
        Sets the epsilon multiplier that controls the maximum distance two learning vectors can be from each other in order to be updated at the same time. If they are too far apart, only one can be updated. It is recommended to use a value in the range [0.1, 0.3]
        Parameters:
        eps - the scale factor of the maximum distance for two learning vectors to be updated at the same time
      • getEpsilonDistance

        public double getEpsilonDistance()
        Sets the epsilon scale distance between learning vectors that may be allowed to two at a time.
        Returns:
        the scale of the allowable distance between learning vectors when updating
      • setLearningRate

        public void setLearningRate(double learningRate)
        Sets the learning rate of the algorithm. It should be set in accordance with setLearningDecay(jsat.math.decayrates.DecayRate).
        Parameters:
        learningRate - the learning rate to use
      • getLearningRate

        public double getLearningRate()
        Returns the learning rate at which to apply updates during the algorithm.
        Returns:
        the learning rate to use
      • setLearningDecay

        public void setLearningDecay(DecayRate learningDecay)
        Sets the decay rate to apply to the learning rate.
        Parameters:
        learningDecay - the rate to decay the learning rate
      • getLearningDecay

        public DecayRate getLearningDecay()
        Returns the method used to decay the learning rate over each iteration
        Returns:
        the decay rate used at each iteration
      • setIterations

        public void setIterations(int iterations)
        Sets the number of learning iterations that will occur.
        Parameters:
        iterations - the number of iterations for the algorithm to use
      • getIterations

        public int getIterations()
        Returns the number of iterations of the algorithm to apply
        Returns:
        the number of iterations to perform
      • setRepresentativesPerClass

        public void setRepresentativesPerClass(int representativesPerClass)
        Sets the number of representatives to create for each class. It is possible to have an unbalanced number of representatives per class, but that is not currently supported. Increasing the number of representatives per class increases the complexity of the decision boundary that can be learned.
        Parameters:
        representativesPerClass - the number of representatives to create for each class
      • getRepresentativesPerClass

        public int getRepresentativesPerClass()
        Returns the number of representatives to create for each class.
        Returns:
        the number of representatives to create for each class.
      • setLVQMethod

        public void setLVQMethod(LVQ.LVQVersion lvqMethod)
        Sets the version of LVQ used.
        Parameters:
        lvqMethod - the version of LVQ to use
      • getLVQMethod

        public LVQ.LVQVersion getLVQMethod()
        Returns the version of the LVQ algorithm to use.
        Returns:
        the version of the LVQ algorithm to use.
      • setDistanceMetric

        public void setDistanceMetric(DistanceMetric dm)
        Sets the distance used for learning
        Parameters:
        dm - the distance metric to use
      • getDistanceMetric

        public DistanceMetric getDistanceMetric()
        Returns the distance metric to use
        Returns:
        the distance metric to use
      • setStoppingDist

        public void setStoppingDist(double stoppingDist)
        The algorithm terminates early if the learning vectors are only moving small distances. The stopping distance is the minimum distance that one of the learning vectors must move for the algorithm to continue.
        Parameters:
        stoppingDist - the minimum distance for each learning vector to move
      • getStoppingDist

        public double getStoppingDist()
        Returns the stopping distance used to terminate the algorithm early
        Returns:
        the stopping distance used toe nd the algorithm early
      • setSeedSelection

        public void setSeedSelection(SeedSelectionMethods.SeedSelection seedSelection)
        Sets the seed selection method used to select the initial learning vectors
        Parameters:
        seedSelection - the method of initialing LVQ
      • setVecCollection

        public void setVecCollection(VectorCollection<VecPaired<Vec,java.lang.Integer>> vcf)
        Sets the vector collection factory to use when storing the final learning vectors
        Parameters:
        vcf - the vector collection factory to use
      • 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 LVQ clone()
        Specified by:
        clone in interface Classifier
        Overrides:
        clone in class java.lang.Object

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.