All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home

Class weka.classifiers.lazy.LBR

java.lang.Object
    |
    +----weka.classifiers.Classifier
            |
            +----weka.classifiers.DistributionClassifier
                    |
                    +----weka.classifiers.lazy.LBR

public class LBR
extends DistributionClassifier
Class for building and using a Lazy Bayesian classifier.
The naive Bayesian classifier provides a simple and effective approach to classifier learning, but its attribute independence assumption is often violated in the real world. A number of approaches have sought to alleviate this problem. A Bayesian tree learning algorithm builds a decision tree, and generates a local naive Bayesian classifier at each leaf. The tests leading to a leaf can alleviate attribute inter­dependencies for the local naive Bayesian classifier. However, Bayesian tree learning still suffers from the small disjunct problem of tree learning. While inferred Bayesian trees demonstrate low average prediction error rates, there is reason to believe that error rates will be higher for those leaves with few training examples.
For more information, see

Zijian Zheng & G. Webb, (2000). Lazy Learning of Bayesian Rules. Machine Learning, 41(1): 53-84.

Author:
Zhihai Wang (Email: zhw@deakin.edu.au) : July 2001 implemented the algorithm
Author:
Jason Wells (Email: wells@deakin.edu.au) : November 2001 added instance referencing via indexes

Class Index

 o LBR.Indexes
Class for handling instances and the associated attributes.

Constructor Index

 o LBR()
 

Method Index

 o binomP(double, double, double)
Significance test binomp:
 o buildClassifier(Instances)
For lazy learning, building classifier is only to prepare their inputs until classification time.
 o distributionForInstance(Instance)
Calculates the class membership probabilities for the given test instance.
 o globalInfo()
 
 o leaveOneOut(LBR.Indexes, int[][][], int[], boolean[])
Leave-one-out strategy.
 o localDistributionForInstance(Instance, LBR.Indexes)
Calculates the class membership probabilities.
 o localNaiveBayes(LBR.Indexes)
Class for building and using a simple Naive Bayes classifier.
 o main(String[])
Main method for testing this class.
 o toString()
Returns a description of the classifier.

Constructor Detail

 o LBR
public LBR()

Method Detail

 o globalInfo
public java.lang.String globalInfo()
Returns:
a description of the classifier suitable for displaying in the explorer/experimenter gui
 o buildClassifier
public void buildClassifier(Instances instances) throws java.lang.Exception
          For lazy learning, building classifier is only to prepare their inputs until classification time.
Parameters:
instances - set of instances serving as training data
Throws:
java.lang.Exception - if the preparation has not been generated.
Overrides:
buildClassifier in class Classifier
 o distributionForInstance
public double[] distributionForInstance(Instance testInstance) throws java.lang.Exception
          Calculates the class membership probabilities for the given test instance. This is the most important method for Lazy Bayesian Rule algorithm.
Parameters:
instance - the instance to be classified
Returns:
predicted class probability distribution
Throws:
java.lang.Exception - if distribution can't be computed
Overrides:
distributionForInstance in class DistributionClassifier
 o toString
public java.lang.String toString()
          Returns a description of the classifier.
Returns:
a description of the classifier as a string.
Overrides:
toString in class java.lang.Object
 o leaveOneOut
public int leaveOneOut(LBR.Indexes instanceIndex,
                       int counts[][][],
                       int priors[],
                       boolean errorFlags[]) throws java.lang.Exception
          Leave-one-out strategy. For a given sample data set with n instances, using (n - 1) instances by leaving one out and tested on the single remaining case. This is repeated n times in turn. The final "Error" is the sum of the instances to be classified incorrectly.
Parameters:
instances - set of instances serving as training data.
counts - serving as all the counts of training data.
priors - serving as the number of instances in each class.
Returns:
error flag array about each instance.
 o localNaiveBayes
public void localNaiveBayes(LBR.Indexes instanceIndex) throws java.lang.Exception
          Class for building and using a simple Naive Bayes classifier. For more information, see

Richard Duda and Peter Hart (1973).Pattern Classification and Scene Analysis. Wiley, New York. This method only get m_Counts and m_Priors.

Parameters:
instances - set of instances serving as training data
Throws:
java.lang.Exception - if m_Counts and m_Priors have not been generated successfully
 o localDistributionForInstance
public double[] localDistributionForInstance(Instance instance,
                                             LBR.Indexes instanceIndex) throws java.lang.Exception
          Calculates the class membership probabilities. for the given test instance.
Parameters:
instance - the instance to be classified
counts - serving as all the counts of training data.
priors - serving as the number of instances in each class.
Returns:
predicted class probability distribution
Throws:
java.lang.Exception - if distribution can't be computed
 o binomP
public double binomP(double r,
                     double n,
                     double p) throws java.lang.Exception
          Significance test binomp:
Parameters:
double - r, double n, double p.
Returns:
returns the probability of obtaining r or fewer out of n if the probability of an event is p.
 o main
public static void main(java.lang.String argv[])
          Main method for testing this class.
Parameters:
argv - the options

All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home