Class NaiveBayes

    • Constructor Detail

      • NaiveBayes

        public NaiveBayes()
    • Method Detail

      • globalInfo

        public String globalInfo()
        Returns a string describing this classifier
        Returns:
        a description of the classifier suitable for displaying in the explorer/experimenter gui
      • getTechnicalInformation

        public TechnicalInformation getTechnicalInformation()
        Returns an instance of a TechnicalInformation object, containing detailed information about the technical background of this class, e.g., paper reference or book this class is based on.
        Specified by:
        getTechnicalInformation in interface TechnicalInformationHandler
        Returns:
        the technical information about this class
      • buildClassifier

        public void buildClassifier​(Instances instances)
                             throws Exception
        Generates the classifier.
        Specified by:
        buildClassifier in interface Classifier
        Parameters:
        instances - set of instances serving as training data
        Throws:
        Exception - if the classifier has not been generated successfully
      • updateClassifier

        public void updateClassifier​(Instance instance)
                              throws Exception
        Updates the classifier with the given instance.
        Parameters:
        instance - the new training instance to include in the model
        Throws:
        Exception - if the instance could not be incorporated in the model.
      • setOptions

        public void setOptions​(String[] options)
                        throws Exception
        Parses a given list of options.

        Valid options are:

         -K
          Use kernel density estimator rather than normal
          distribution for numeric attributes
         
         -D
          Use supervised discretization to process numeric attributes
         
         -O
          Display model in old format (good when there are many classes)
         
        Specified by:
        setOptions in interface OptionHandler
        Overrides:
        setOptions in class AbstractClassifier
        Parameters:
        options - the list of options as an array of strings
        Throws:
        Exception - if an option is not supported
      • toString

        public String toString()
        Returns a description of the classifier.
        Overrides:
        toString in class Object
        Returns:
        a description of the classifier as a string.
      • useKernelEstimatorTipText

        public String useKernelEstimatorTipText()
        Returns the tip text for this property
        Returns:
        tip text for this property suitable for displaying in the explorer/experimenter gui
      • getUseKernelEstimator

        public boolean getUseKernelEstimator()
        Gets if kernel estimator is being used.
        Returns:
        Value of m_UseKernelEstimatory.
      • setUseKernelEstimator

        public void setUseKernelEstimator​(boolean v)
        Sets if kernel estimator is to be used.
        Parameters:
        v - Value to assign to m_UseKernelEstimatory.
      • useSupervisedDiscretizationTipText

        public String useSupervisedDiscretizationTipText()
        Returns the tip text for this property
        Returns:
        tip text for this property suitable for displaying in the explorer/experimenter gui
      • getUseSupervisedDiscretization

        public boolean getUseSupervisedDiscretization()
        Get whether supervised discretization is to be used.
        Returns:
        true if supervised discretization is to be used.
      • setUseSupervisedDiscretization

        public void setUseSupervisedDiscretization​(boolean s)
        Set whether supervised discretization is to be used.
        Parameters:
        s - true if supervised discretization is to be used.
      • displayModelInOldFormatTipText

        public String displayModelInOldFormatTipText()
        Returns the tip text for this property
        Returns:
        tip text for this property suitable for displaying in the explorer/experimenter gui
      • setDisplayModelInOldFormat

        public void setDisplayModelInOldFormat​(boolean d)
        Set whether to display model output in the old, original format.
        Parameters:
        d - true if model ouput is to be shown in the old format
      • getDisplayModelInOldFormat

        public boolean getDisplayModelInOldFormat()
        Get whether to display model output in the old, original format.
        Returns:
        true if model ouput is to be shown in the old format
      • getHeader

        public Instances getHeader()
        Return the header that this classifier was trained with
        Returns:
        the header that this classifier was trained with
      • getConditionalEstimators

        public Estimator[][] getConditionalEstimators()
        Get all the conditional estimators.
        Returns:
        all the conditional estimators.
      • getClassEstimator

        public Estimator getClassEstimator()
        Get the class estimator.
        Returns:
        the class estimator
      • finalizeAggregation

        public void finalizeAggregation()
                                 throws Exception
        Description copied from interface: Aggregateable
        Call to complete the aggregation process. Allows implementers to do any final processing based on how many objects were aggregated.
        Specified by:
        finalizeAggregation in interface Aggregateable<NaiveBayes>
        Throws:
        Exception - if the aggregation can't be finalized for some reason
      • main

        public static void main​(String[] argv)
        Main method for testing this class.
        Parameters:
        argv - the options