Package weka.classifiers.trees.j48
Class NBTreeNoSplit
- java.lang.Object
-
- weka.classifiers.trees.j48.ClassifierSplitModel
-
- weka.classifiers.trees.j48.NBTreeNoSplit
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,RevisionHandler
public final class NBTreeNoSplit extends ClassifierSplitModel
Class implementing a "no-split"-split (leaf node) for naive bayes trees.- Version:
- $Revision: 1.4 $
- Author:
- Mark Hall (mhall@cs.waikato.ac.nz)
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description NBTreeNoSplit()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbuildClassifier(Instances instances)Build the no-split nodedoubleclassProb(int classIndex, Instance instance, int theSubset)Return the probability for a class valuestatic doublecrossValidate(NaiveBayesUpdateable fullModel, Instances trainingSet, java.util.Random r)Utility method for fast 5-fold cross validation of a naive bayes modelDiscretizegetDiscretizer()Return the discretizer used at this nodedoublegetErrors()Return the errors made by the naive bayes model at this nodeNaiveBayesUpdateablegetNaiveBayesModel()Get the naive bayes model at this nodejava.lang.StringgetRevision()Returns the revision string.java.lang.StringleftSide(Instances instances)Does nothing because no condition has to be satisfied.java.lang.StringrightSide(int index, Instances instances)Does nothing because no condition has to be satisfied.java.lang.StringsourceExpression(int index, Instances data)Returns a string containing java source code equivalent to the test made at this node.java.lang.StringtoString()Return a textual description of the nodedouble[]weights(Instance instance)Always returns null because there is only one subset.intwhichSubset(Instance instance)Always returns 0 because only there is only one subset.-
Methods inherited from class weka.classifiers.trees.j48.ClassifierSplitModel
checkModel, classifyInstance, classProbLaplace, clone, codingCost, distribution, dumpLabel, dumpModel, numSubsets, resetDistribution, sourceClass, split
-
-
-
-
Method Detail
-
buildClassifier
public final void buildClassifier(Instances instances) throws java.lang.Exception
Build the no-split node- Specified by:
buildClassifierin classClassifierSplitModel- Parameters:
instances- anInstancesvalue- Throws:
java.lang.Exception- if an error occurs
-
getErrors
public double getErrors()
Return the errors made by the naive bayes model at this node- Returns:
- the number of errors made
-
getDiscretizer
public Discretize getDiscretizer()
Return the discretizer used at this node- Returns:
- a
Discretizevalue
-
getNaiveBayesModel
public NaiveBayesUpdateable getNaiveBayesModel()
Get the naive bayes model at this node- Returns:
- a
NaiveBayesUpdateablevalue
-
whichSubset
public final int whichSubset(Instance instance)
Always returns 0 because only there is only one subset.- Specified by:
whichSubsetin classClassifierSplitModel
-
weights
public final double[] weights(Instance instance)
Always returns null because there is only one subset.- Specified by:
weightsin classClassifierSplitModel
-
leftSide
public final java.lang.String leftSide(Instances instances)
Does nothing because no condition has to be satisfied.- Specified by:
leftSidein classClassifierSplitModel- Parameters:
instances- the data.
-
rightSide
public final java.lang.String rightSide(int index, Instances instances)Does nothing because no condition has to be satisfied.- Specified by:
rightSidein classClassifierSplitModel
-
sourceExpression
public final java.lang.String sourceExpression(int index, Instances data)Returns a string containing java source code equivalent to the test made at this node. The instance being tested is called "i".- Specified by:
sourceExpressionin classClassifierSplitModel- Parameters:
index- index of the nominal value testeddata- the data containing instance structure info- Returns:
- a value of type 'String'
-
classProb
public double classProb(int classIndex, Instance instance, int theSubset) throws java.lang.ExceptionReturn the probability for a class value- Overrides:
classProbin classClassifierSplitModel- Parameters:
classIndex- the index of the class valueinstance- the instance to generate a probability fortheSubset- the subset to consider- Returns:
- a probability
- Throws:
java.lang.Exception- if an error occurs
-
toString
public java.lang.String toString()
Return a textual description of the node- Overrides:
toStringin classjava.lang.Object- Returns:
- a
Stringvalue
-
crossValidate
public static double crossValidate(NaiveBayesUpdateable fullModel, Instances trainingSet, java.util.Random r) throws java.lang.Exception
Utility method for fast 5-fold cross validation of a naive bayes model- Parameters:
fullModel- aNaiveBayesUpdateablevaluetrainingSet- anInstancesvaluer- aRandomvalue- Returns:
- a
doublevalue - Throws:
java.lang.Exception- if an error occurs
-
getRevision
public java.lang.String getRevision()
Returns the revision string.- Returns:
- the revision
-
-