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

Class RBFNet

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


    public class RBFNet
    extends java.lang.Object
    implements Classifier, Regressor, DataTransform, Parameterized
    This provides a highly configurable implementation of a Radial Basis Function Neural Network. A RBF network is a type of neural network that contains one hidden layer, and is related to the LVQ algorithm. In a classical RBF Network, the distance between two data points is generally the EuclideanDistance or MahalanobisDistance. This implementation allows the specification of any arbitrary distance metric.

    Another restriction on classical RBF Nets is that a weighted sum of the output of the hidden units be used to make the final decision. Instead this implementation allows the specification of an arbitrary Classifier or Regressor to estimate the outputs based on the hidden unit activations. Whether or not the predictor supports Classification, Regression, and what classification features it supports - will determine what the RBF Network supports. This allows for models technically more complicated and powerful than the standard RBF network.

    The initial phases of a RBF Network is to learn the neuron locations and activations. This part can also be seen as learning a data transformation. As such, the RBF Network can be used as a DataTransform itself.
    The last phase of the network is to learn the model based on the data point activations.

    It is highly recommended to use a base learning method that can efficiently use sparse vectors.
    See Also:
    Serialized Form
    • Constructor Detail

      • RBFNet

        public RBFNet(int numCentroids)
        Creates a new RBF Network suitable for binary classification or regression. One of the other constructors should be used if you need classification for multi-class or if you need probability outputs.

        This will use RBFNet.Phase1Learner.K_MEANS for neuron selection and RBFNet.Phase2Learner.NEAREST_OTHER_CENTROID_AVERAGE for activation tuning. The EuclideanDistance will be use as the metric.
        Parameters:
        numCentroids - the number of centroids or neurons to use in the network's hidden layer
      • RBFNet

        public RBFNet(int numCentroids,
                      RBFNet.Phase1Learner cl,
                      RBFNet.Phase2Learner bl,
                      double alpha,
                      int p,
                      DistanceMetric dm,
                      Classifier baseClassifier)
        Creates a new RBF Network for classification tasks. If the classifier can also perform regression, then the network will be able to perform both.
        Parameters:
        numCentroids - the number of centroids or neurons to use in the network's hidden layer
        cl - the method to learn the neuron locations
        bl - the method to learn the neuron activations
        alpha - a parameter that may have an effect on the neuron activation learning method.
        p - a parameter that may have an effect on the neuron activation learning method
        dm - the distance metric to use
        baseClassifier - the base classifier to learn on top of the hidden layer activations.
      • RBFNet

        public RBFNet(int numCentroids,
                      RBFNet.Phase1Learner cl,
                      RBFNet.Phase2Learner bl,
                      double alpha,
                      int p,
                      DistanceMetric dm,
                      Regressor baseRegressor)
        Creates a new RBF Network for regression tasks. If the regressor can also perform classification, then the network will be able to perform both.
        Parameters:
        numCentroids - the number of centroids or neurons to use in the network's hidden layer
        cl - the method to learn the neuron locations
        bl - the method to learn the neuron activations
        alpha - a parameter that may have an effect on the neuron activation learning method.
        p - a parameter that may have an effect on the neuron activation learning method
        dm - the distance metric to use
        baseRegressor - the base regressor to learn on op of the hidden layer activations.
      • RBFNet

        public RBFNet(RBFNet toCopy)
        Copy constructor
        Parameters:
        toCopy - the network to copy
    • Method Detail

      • transform

        public DataPoint transform(DataPoint dp)
        Description copied from interface: DataTransform
        Returns a new data point that is a transformation of the original data point. This new data point is a different object, but may contain the same references as the original data point. It is not guaranteed that you can mutate the transformed point without having a side effect on the original point.
        Specified by:
        transform in interface DataTransform
        Parameters:
        dp - the data point to apply a transformation to
        Returns:
        a transformed data point
      • setAlpha

        public void setAlpha(double alpha)
        Sets the alpha parameter. This value is used for certain RBFNet.Phase2Learner learners as a parameter. A good default value for most methods is often 1 or 3. However the parameter must always be a non-negative value.
        Parameters:
        alpha - a non negative value that controls the width of the learned bandwidths.
      • getAlpha

        public double getAlpha()
        Returns the alpha bandwidth learning parameter
        Returns:
        the alpha bandwidth learning parameter
        See Also:
        setAlpha(double)
      • guessAlpha

        public static Distribution guessAlpha(DataSet data)
        Guesses the distribution for the setAlpha(double) parameter
        Parameters:
        data - the data to create a guess for
        Returns:
        a guess for the distribution of the Alpha parameter
      • setP

        public void setP(int p)
        Sets the nearest neighbor parameter. This value is used for certain RBFNet.Phase2Learner learners as a parameter. It is used to control the number of neighbors taken into account in learning the parameter value. It must always be a positive value. 3 is usually a good value for this parameter.
        Parameters:
        p - the positive integer used that controls the width of the learned bandwidths
      • getP

        public int getP()
        Returns the nearest neighbors parameter.
        Returns:
        the nearest neighbors parameter.
        See Also:
        setP(int)
      • guessP

        public static Distribution guessP(DataSet data)
        Guesses the distribution for the setP(int) parameter
        Parameters:
        data - the data to create a guess for
        Returns:
        a guess for the distribution of the P parameter
      • setNumCentroids

        public void setNumCentroids(int numCentroids)
        Sets the number of centroids to learn for this model. Increasing the number of centroids increases the complexity of the model as well as training and evaluation time. The centroids serve as the hidden units in the network.

        The centroids learned are controlled via the setPhase1Learner(jsat.classifiers.neuralnetwork.RBFNet.Phase1Learner) method
        Parameters:
        numCentroids - the number of centroids to use in the model
      • getNumCentroids

        public int getNumCentroids()
        Returns the number of centroids to use when training
        Returns:
        * Returns the number of centroids to use when training
      • guessNumCentroids

        public static Distribution guessNumCentroids(DataSet data)
        Guesses the distribution for the setNumCentroids(int) parameter
        Parameters:
        data - the data to create a guess for
        Returns:
        a guess for the distribution of the number of centroids to use
      • setDistanceMetric

        public void setDistanceMetric(DistanceMetric dm)
        Sets the distance metric used to determine neuron activations.
        Parameters:
        dm - the distance metric to use
      • getDistanceMetric

        public DistanceMetric getDistanceMetric()
        Returns the distance metric in use
        Returns:
        the distance metric in use
      • setPhase1Learner

        public void setPhase1Learner(RBFNet.Phase1Learner p1l)
        Sets the method used for learning the centroids (or hidden units) of the network.
        Parameters:
        p1l - the learning method to use
      • getPhase1Learner

        public RBFNet.Phase1Learner getPhase1Learner()
        Returns the method to use for learning the centroids of the network.
        Returns:
        the method to use for learning the centroids of the network.
      • setPhase2Learner

        public void setPhase2Learner(RBFNet.Phase2Learner p2l)
        Sets the method used for learning the bandwidths for each centroid in the network. Depending on the method used, setAlpha(double) or setP(int) may impact the learned bandwidths.
        Parameters:
        p2l - the learning method to use
      • getPhase2Learner

        public RBFNet.Phase2Learner getPhase2Learner()
        Returns the learning method to use for determining the bandwidths of each center in the network.
        Returns:
        the learning method to use for the bandwidths
      • setNormalize

        public void setNormalize(boolean normalize)
        Sets whether or not to normalize the outputs of the neurons in the network so that the activations sum to one. Normalizing the outputs can increase the generalization ability of the network. By default this is set to true
        Parameters:
        normalize - true to normalize the neuron outputs, false to use the raw activation values.
      • isNormalize

        public boolean isNormalize()
        Returns whether or not the network is currently normalizing its neuron outputs.
        Returns:
        whether or not the neuron outputs are normalized
      • 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
        Specified by:
        supportsWeightedData in interface Regressor
        Returns:
        true if the model supports weighted data, false otherwise
      • fit

        public void fit(DataSet data)
        Description copied from interface: DataTransform
        Fits this transform to the given dataset. Some transforms can only be learned from classification or regression datasets. If an incompatible dataset type is given, a FailedToFitException exception may be thrown.
        Specified by:
        fit in interface DataTransform
        Parameters:
        data - the dataset to fir this transform to

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.