Documentation of 'jsat.classifiers.linear.PassiveAggressive' Java class
PassiveAggressive
jsat.classifiers.linear

Class PassiveAggressive

    • Constructor Detail

      • PassiveAggressive

        public PassiveAggressive()
        Creates a new Passive Aggressive learner that does 10 epochs and uses PassiveAggressive.Mode.PA1
      • PassiveAggressive

        public PassiveAggressive(int epochs,
                                 PassiveAggressive.Mode mode)
        Creates a new Passive Aggressive learner
        Parameters:
        epochs - the number of training epochs to use during batch training
        mode - which version of the update to perform
    • Method Detail

      • setC

        public void setC(double C)
        Set the aggressiveness parameter. Increasing the value of this parameter increases the aggressiveness of the algorithm. It must be a positive value. This parameter essentially performs a type of regularization on the updates
        An infinitely large value is equivalent to being completely aggressive, and is performed when the mode is set to PassiveAggressive.Mode.PA.
        Parameters:
        C - the positive aggressiveness parameter
      • getC

        public double getC()
        Returns the aggressiveness parameter
        Returns:
        the aggressiveness parameter
      • setMode

        public void setMode(PassiveAggressive.Mode mode)
        Sets which version of the PA update is used.
        Parameters:
        mode - which PA update style to perform
      • getMode

        public PassiveAggressive.Mode getMode()
        Returns which version of the PA update is used
        Returns:
        which PA update style is used
      • setEps

        public void setEps(double eps)
        Sets the range for numerical prediction. If it is within range of the given value, no error will be incurred.
        Parameters:
        eps - the maximum acceptable difference in prediction and truth
      • getEps

        public double getEps()
        Returns the maximum acceptable difference in prediction and truth
        Returns:
        the maximum acceptable difference in prediction and truth
      • setEpochs

        public void setEpochs(int epochs)
        Sets the number of whole iterations through the training set that will be performed for training
        Parameters:
        epochs - the number of whole iterations through the data set
      • getEpochs

        public int getEpochs()
        Returns the number of epochs used for training
        Returns:
        the number of epochs used for training
      • getBias

        public double getBias()
        Description copied from interface: SingleWeightVectorModel
        Returns the bias term used for the model, or 0 of the model does not support or was not trained with a bias term.
        Specified by:
        getBias in interface SingleWeightVectorModel
        Returns:
        the bias term for the model
      • getRawWeight

        public Vec getRawWeight(int index)
        Description copied from interface: SimpleWeightVectorModel
        Returns the raw weight vector associated with the given class index. If the given class is an implicit zero vector, a ConstantVector object may be returned.
        Do not alter the returned weight vector, as it will change the model's values.

        If a regression problem, only index = 0 should be used
        Specified by:
        getRawWeight in interface SimpleWeightVectorModel
        Parameters:
        index - the class index to get the weight vector for
        Returns:
        the weight vector used for the specified class
      • getBias

        public double getBias(int index)
        Description copied from interface: SimpleWeightVectorModel
        Returns the bias term used with the weight vector for the given class index. If the model does not support or was not trained with bias weights, 0 will be returned.

        If a regression problem, only index = 0 should be used
        Specified by:
        getBias in interface SimpleWeightVectorModel
        Parameters:
        index - the class index to get the weight vector for
        Returns:
        the bias term for the specified class
      • numWeightsVecs

        public int numWeightsVecs()
        Description copied from interface: SimpleWeightVectorModel
        Returns the number of weight vectors that can be returned. For binary classification problems the value may be 1 if only a single weight vector's sign is used to determine the class. For multi-class problems, the weight vector count includes the implicit zero vector (if one is being used).
        Specified by:
        numWeightsVecs in interface SimpleWeightVectorModel
        Returns:
        the number of weight vectors for which SimpleWeightVectorModel.getRawWeight(int) can be called.
      • 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.
      • getScore

        public double getScore(DataPoint dp)
        Description copied from interface: BinaryScoreClassifier
        Returns the numeric score for predicting a class of a given data point, where the sign of the value indicates which class the data point is predicted to belong to.
        Specified by:
        getScore in interface BinaryScoreClassifier
        Parameters:
        dp - the data point to predict the class label of
        Returns:
        the score for the given data point
      • 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.
      • train

        public void train(ClassificationDataSet dataSet)
        Description copied from interface: Classifier
        Trains the classifier and constructs a model for classification using the given data set.
        Specified by:
        train in interface Classifier
        Parameters:
        dataSet - the data set to train on
      • 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
      • update

        public void update(DataPoint dataPoint,
                           int targetClass)
        Description copied from interface: UpdateableClassifier
        Updates the classifier by giving it a new data point to learn from.
        Specified by:
        update in interface UpdateableClassifier
        Parameters:
        dataPoint - the data point to learn
        targetClass - the target class of the data point
      • update

        public void update(DataPoint dataPoint,
                           double targetValue)
        Description copied from interface: UpdateableRegressor
        Updates the classifier by giving it a new data point to learn from.
        Specified by:
        update in interface UpdateableRegressor
        Parameters:
        dataPoint - the data point to learn
        targetValue - the target value of the data point
      • guessC

        public static Distribution guessC(DataSet d)
        Guess the distribution to use for the regularization term C in PassiveAggressive.
        Parameters:
        d - the data set to get the guess for
        Returns:
        the guess for the C parameter

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.