Documentation of 'jsat.classifiers.linear.kernelized.OSKL' Java class
OSKL
jsat.classifiers.linear.kernelized

Class OSKL

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


    public class OSKL
    extends BaseUpdateableClassifier
    implements BinaryScoreClassifier, Parameterized
    Online Sparse Kernel Learning by Sampling and Smooth Losses (OSKL) is an online algorithm for learning sparse kernelized solutions to binary classification problems. The number of support vectors is controlled by a a sparsity parameter G and a specified loss function. The number of support vectors is bounded by the cumulative loss of the loss function used.

    The OSKL algorithm is designed for use with smooth loss functions such as the logistic loss. However, it can work with non-smooth loss functions such as the hinge loss.

    See: Zhang, L., Yi, J., Jin, R., Lin, M.,&He, X. (2013). Online Kernel Learning with a Near Optimal Sparsity Bound. In S. Dasgupta&D. Mcallester (Eds.), Proceedings of the 30th International Conference on Machine Learning (ICML-13) (Vol. 28, pp. 621–629). JMLR Workshop and Conference Proceedings.
    See Also:
    Serialized Form
    • Constructor Detail

      • OSKL

        public OSKL(KernelTrick k,
                    double R)
        Creates a new OSKL learner using the LogisticLoss. The parameters setG(double) and setEta(double) are set based on the original papers suggestions to produced a less sparse model that should be more accurate
        Parameters:
        k - the kernel to use
        R - the maximum allowed norm for the model
      • OSKL

        public OSKL(KernelTrick k,
                    double eta,
                    double G,
                    double R)
        Creates a new OSKL learner using the LogisticLoss
        Parameters:
        k - the kernel to use
        eta - the learning rate to use
        G - the sparsification parameter
        R - the maximum allowed norm for the model
      • OSKL

        public OSKL(KernelTrick k,
                    double eta,
                    double G,
                    double R,
                    LossC lossC)
        Creates a new OSKL learner
        Parameters:
        k - the kernel to use
        eta - the learning rate to use
        G - the sparsification parameter
        R - the maximum allowed norm for the model
        lossC - the loss function to use
      • OSKL

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

      • setKernel

        public void setKernel(KernelTrick k)
        Sets the kernel to use
        Parameters:
        k - the kernel to use
      • getKernel

        public KernelTrick getKernel()
        Returns the kernel to use
        Returns:
        the kernel to use
      • setEta

        public void setEta(double eta)
        Sets the learning rate to use for training. The original paper suggests setting η = 0.9/G
        Parameters:
        eta - the positive learning rate to use
      • getEta

        public double getEta()
        Returns the learning rate in use
        Returns:
        the learning rate in use
      • setG

        public void setG(double G)
        Sets the sparsification parameter G. Increasing G reduces the number of updates to the model, which increases sparsity but may reduce accuracy. Decreasing G increases the update rate reducing sparsity. The original paper tests values of G ∈ {1, 2, 4, 10}
        Parameters:
        G - the sparsification parameter in [1, ∞)
      • getG

        public double getG()
        Returns the sparsification parameter
        Returns:
        the sparsification parameter
      • guessR

        public static Distribution guessR(DataSet d)
        Guesses the distribution to use for the R parameter
        Parameters:
        d - the dataset to get the guess for
        Returns:
        the guess for the R parameter
        See Also:
        setR(double)
      • setR

        public void setR(double R)
        Sets the maximum allowed norm of the model. The original paper suggests values in the range 10x for x ∈ {0, 1, 2, 3, 4, 5}.
        Parameters:
        R - the maximum allowed norm for the model
      • getR

        public double getR()
        Returns the maximum allowed norm for the model learned
        Returns:
        the maximum allowed norm for the model learned
      • setUseAverageModel

        public void setUseAverageModel(boolean useAverageModel)
        Sets whether or not the average of all intermediate models is used or if the most recent model is used when performing classification
        Parameters:
        useAverageModel - true to use the average model, false to use the last model update
      • isUseAverageModel

        public boolean isUseAverageModel()
        Returns true if the average of all models is being used, or false if the last model is used
        Returns:
        true if the average of all models is being used, or false if the last model is used
      • setBurnIn

        public void setBurnIn(int burnIn)
        Sets the number of update calls to consider as part of the "burn in" phase. The averaging of the model will not start until after the burn in phase.
        If the classification or score is requested before the burn in phase is completed, the latest model will be used as is.
        Parameters:
        burnIn - the number of updates to ignore before averaging. Must be non negative.
      • getBurnIn

        public int getBurnIn()
        Returns the number of burn in rounds
        Returns:
        the number of burn in rounds
      • getSupportVectorCount

        public int getSupportVectorCount()
        Returns the number of data points accepted as support vectors
        Returns:
        the number of support vectors in the model
      • 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
      • 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.
      • 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
      • 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

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.