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

Class LinearBatch

    • Constructor Detail

      • LinearBatch

        public LinearBatch()
        Creates a new Linear Batch learner for classification using a small regularization term
      • LinearBatch

        public LinearBatch(LossFunc loss,
                           double lambda0)
        Creates a new Linear Batch learner
        Parameters:
        loss - the loss function to use
        lambda0 - the L2 regularization term
      • LinearBatch

        public LinearBatch(LossFunc loss,
                           double lambda0,
                           double tolerance)
        Creates a new Linear Batch learner
        Parameters:
        loss - the loss function to use
        lambda0 - the L2 regularization term
        tolerance - the threshold for convergence
      • LinearBatch

        public LinearBatch(LossFunc loss,
                           double lambda0,
                           double tolerance,
                           Optimizer optimizer)
        Creates a new Linear Batch learner
        Parameters:
        loss - the loss function to use
        lambda0 - the L2 regularization term
        tolerance - the threshold for convergence
        optimizer - the batch optimization method to use
      • LinearBatch

        public LinearBatch(LinearBatch toCopy)
        Copy constructor
        Parameters:
        toCopy - the object to copy
    • Method Detail

      • setUseBiasTerm

        public void setUseBiasTerm(boolean useBiasTerm)
      • isUseBiasTerm

        public boolean isUseBiasTerm()
      • setLambda0

        public void setLambda0(double lambda0)
        λ0 controls the L2 regularization penalty.
        Parameters:
        lambda0 - the L2 regularization penalty to use
      • getLambda0

        public double getLambda0()
        Returns the L2 regularization term in use
        Returns:
        the L2 regularization term in use
      • setLoss

        public void setLoss(LossFunc loss)
        Sets the loss function used for the model. The loss function controls whether or not regression, binary classification, or multi-class classification is supported.
        Parameters:
        loss - the loss function to use
      • getLoss

        public LossFunc getLoss()
        Returns the loss function in use
        Returns:
        the loss function in use
      • setOptimizer

        public void setOptimizer(Optimizer optimizer)
        Sets the method of batch optimization that will be used. null is valid for this value, in which case the implementation will attempt to select a reasonable optimizer automatically.

        NOTE: the current implementation requires the optimizer to work based off only the function value and its derivative.
        Parameters:
        optimizer - the method to use for function minimization
      • getOptimizer

        public Optimizer getOptimizer()
        Returns the optimization method in use, or null.
        Returns:
        the optimization method in use, or null.
      • setTolerance

        public void setTolerance(double tolerance)
        Sets the convergence tolerance to user for training. Smaller values reach a more accuracy solution but may take longer to complete.
        While zero is a valid tolerance value, it is not usually useful in practice. Values in [10-4, 10-2] are usually more practical.
        Parameters:
        tolerance - the convergence tolerance
      • getTolerance

        public double getTolerance()
        Returns the value of the convergence tolerance parameter
        Returns:
        the convergence tolerance parameter
      • 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 D,
                          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:
        D - 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 D,
                          Classifier warmSolution,
                          boolean parallel)
        Description copied from interface: WarmClassifier
        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 WarmClassifier
        Parameters:
        D - the data set to train on
        warmSolution - the solution to use to warm start this model
        parallel - true if the training should be done using multiple-cores, false for single threaded.
      • train

        public void train(RegressionDataSet dataSet,
                          Regressor warmSolution)
        Description copied from interface: WarmRegressor
        Trains the regressor and constructs a model for regression using the given data set.
        Specified by:
        train in interface WarmRegressor
        Parameters:
        dataSet - the data set to train on
        warmSolution - the solution to use to warm start this model
      • train

        public void train(RegressionDataSet D,
                          Regressor warmSolution,
                          boolean parallel)
        Description copied from interface: WarmRegressor
        Trains the regressor and constructs a model for regression 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 WarmRegressor
        Parameters:
        D - the data set to train on
        warmSolution - the solution to use to warm start this model
        parallel - true if the training should be done using multiple-cores, false for single threaded.
      • warmFromSameDataOnly

        public boolean warmFromSameDataOnly()
        Description copied from interface: WarmClassifier
        Some models can only be warm started from a solution trained on the exact same data set as the model it is warm starting from. If this is the case true will be returned. The behavior for training on a different data set when this is defined is undefined. It may cause an error, or it may cause the algorithm to take longer or reach a worse solution.
        When true, it is important that the data set be unaltered - this includes mutating the values stored or re-arranging the data points within the data set.
        Specified by:
        warmFromSameDataOnly in interface WarmClassifier
        Specified by:
        warmFromSameDataOnly in interface WarmRegressor
        Returns:
        true if the algorithm can only be warm started from the model trained on the exact same data set.
      • 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.
      • 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
      • guessLambda0

        public static Distribution guessLambda0(DataSet d)
        Guess the distribution to use for the regularization term λ0 .
        Parameters:
        d - the data set to get the guess for
        Returns:
        the guess for the λ0 parameter

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.