Documentation of 'jsat.classifiers.bayesian.NaiveBayes' Java class
NaiveBayes
jsat.classifiers.bayesian

Class NaiveBayes

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


    public class NaiveBayes
    extends java.lang.Object
    implements Classifier, Parameterized
    Provides an implementation of the Naive Bayes classifier that assumes numeric features come from some continuous probability distribution. By default this implementation restricts itself to only the Gaussian distribution, and becomes Gaussian Naive Bayes. Other distributions are supported, and a KernelDensityEstimator can be used as well.

    By default, this implementation assumes that the input vectors are sparse and the distribution will only be estimated by the non-zero values, and features that are zero will be ignored during prediction time. This should be turned off when using dense data by calling setSparceInput(boolean)

    Naive Bayes assumes that all attributes are perfectly independent.
    See Also:
    Serialized Form
    • Constructor Detail

      • NaiveBayes

        public NaiveBayes(NaiveBayes.NumericalHandeling numericalHandling)
        Creates a new Naive Bayes classifier that uses the specific method for handling numeric features.
        Parameters:
        numericalHandling - the method to use for numeric features
      • NaiveBayes

        public NaiveBayes()
        Creates a new Gaussian Naive Bayes classifier
    • Method Detail

      • setNumericalHandling

        public void setNumericalHandling(NaiveBayes.NumericalHandeling numericalHandling)
        Sets the method used by this instance for handling numerical attributes. This has no effect on an already trained classifier, but will change the result if trained again.
        Parameters:
        numericalHandling - the method to use for numerical attributes
      • getNumericalHandling

        public NaiveBayes.NumericalHandeling getNumericalHandling()
        Returns the method used to handle numerical attributes
        Returns:
        the method used to handle numerical attributes
      • isSparceInput

        public boolean isSparceInput()
        Returns true if the Classifier assumes that data points are sparce.
        Returns:
        true if the Classifier assumes that data points are sparce.
        See Also:
        setSparceInput(boolean)
      • setSparceInput

        public void setSparceInput(boolean sparceInput)
        Tells the Naive Bayes classifier to assume the importance of sparseness in the numerical values. This means that values of zero will be ignored in computation and classification.
        This allows faster, more efficient computation of results if the data points are indeed sparce. This will also produce different results. This value should not be changed after training and before classification.
        Parameters:
        sparceInput - true to assume sparseness in the data, false to ignore it and assume zeros are meaningful values.
        See Also:
        isSparceInput()
      • 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.
      • clone

        public NaiveBayes clone()
        Specified by:
        clone in interface Classifier
        Overrides:
        clone in class java.lang.Object
      • 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
      • 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.

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.