Package weka.classifiers.lazy
Class LBR
java.lang.Object
weka.classifiers.Classifier
weka.classifiers.lazy.LBR
- All Implemented Interfaces:
Serializable
,Cloneable
,CapabilitiesHandler
,OptionHandler
,RevisionHandler
,TechnicalInformationHandler
Lazy Bayesian Rules 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. Lazy Bayesian Rules selectively relaxes the independence assumption, achieving lower error rates over a range of learning tasks. LBR defers processing to classification time, making it a highly efficient and accurate classification algorithm when small numbers of objects are to be classified.
For more information, see:
Zijian Zheng, G. Webb (2000). Lazy Learning of Bayesian Rules. Machine Learning. 4(1):53-84. BibTeX:
For more information, see:
Zijian Zheng, G. Webb (2000). Lazy Learning of Bayesian Rules. Machine Learning. 4(1):53-84. BibTeX:
@article{Zheng2000, author = {Zijian Zheng and G. Webb}, journal = {Machine Learning}, number = {1}, pages = {53-84}, title = {Lazy Learning of Bayesian Rules}, volume = {4}, year = {2000} }Valid options are:
-D If set, classifier is run in debug mode and may output additional info to the console
- Version:
- $Revision: 5525 $
- Author:
- Zhihai Wang (zhw@deakin.edu.au) : July 2001 implemented the algorithm, Jason Wells (wells@deakin.edu.au) : November 2001 added instance referencing via indexes
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
Class for handling instances and the associated attributes. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondouble
binomP
(double r, double n, double p) Significance test binomp:void
buildClassifier
(Instances instances) For lazy learning, building classifier is only to prepare their inputs until classification time.double[]
distributionForInstance
(Instance testInstance) Calculates the class membership probabilities for the given test instance.Returns default capabilities of the classifier.Returns the revision string.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.int
leaveOneOut
(LBR.Indexes instanceIndex, int[][][] counts, int[] priors, boolean[] errorFlags) Leave-one-out strategy.double[]
localDistributionForInstance
(Instance instance, LBR.Indexes instanceIndex) Calculates the class membership probabilities.void
localNaiveBayes
(LBR.Indexes instanceIndex) Class for building and using a simple Naive Bayes classifier.static void
Main method for testing this class.toString()
Returns a description of the classifier.Methods inherited from class weka.classifiers.Classifier
classifyInstance, debugTipText, forName, getDebug, getOptions, listOptions, makeCopies, makeCopy, setDebug, setOptions
-
Constructor Details
-
LBR
public LBR()
-
-
Method Details
-
globalInfo
- Returns:
- a description of the classifier suitable for displaying in the explorer/experimenter gui
-
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 interfaceTechnicalInformationHandler
- Returns:
- the technical information about this class
-
getCapabilities
Returns default capabilities of the classifier.- Specified by:
getCapabilities
in interfaceCapabilitiesHandler
- Overrides:
getCapabilities
in classClassifier
- Returns:
- the capabilities of this classifier
- See Also:
-
buildClassifier
For lazy learning, building classifier is only to prepare their inputs until classification time.- Specified by:
buildClassifier
in classClassifier
- Parameters:
instances
- set of instances serving as training data- Throws:
Exception
- if the preparation has not been generated.
-
distributionForInstance
Calculates the class membership probabilities for the given test instance. This is the most important method for Lazy Bayesian Rule algorithm.- Overrides:
distributionForInstance
in classClassifier
- Parameters:
testInstance
- the instance to be classified- Returns:
- predicted class probability distribution
- Throws:
Exception
- if distribution can't be computed
-
toString
Returns a description of the classifier. -
leaveOneOut
public int leaveOneOut(LBR.Indexes instanceIndex, int[][][] counts, int[] priors, boolean[] errorFlags) throws 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:
instanceIndex
- 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.errorFlags
- for the errors- Returns:
- error flag array about each instance.
- Throws:
Exception
- if something goes wrong
-
localNaiveBayes
Class for building and using a simple Naive Bayes classifier. For more information, seeRichard Duda and Peter Hart (1973).Pattern Classification and Scene Analysis. Wiley, New York. This method only get m_Counts and m_Priors.
- Parameters:
instanceIndex
- set of instances serving as training data- Throws:
Exception
- if m_Counts and m_Priors have not been generated successfully
-
localDistributionForInstance
public double[] localDistributionForInstance(Instance instance, LBR.Indexes instanceIndex) throws Exception Calculates the class membership probabilities. for the given test instance.- Parameters:
instance
- the instance to be classifiedinstanceIndex
-- Returns:
- predicted class probability distribution
- Throws:
Exception
- if distribution can't be computed
-
binomP
Significance test binomp:- Parameters:
r
-n
-p
-- Returns:
- returns the probability of obtaining r or fewer out of n if the probability of an event is p.
- Throws:
Exception
- if computation fails
-
getRevision
Returns the revision string.- Specified by:
getRevision
in interfaceRevisionHandler
- Overrides:
getRevision
in classClassifier
- Returns:
- the revision
-
main
Main method for testing this class.- Parameters:
argv
- the options
-