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 void
buildClassifier(Instances instances)
Build the no-split nodedouble
classProb(int classIndex, Instance instance, int theSubset)
Return the probability for a class valuestatic double
crossValidate(NaiveBayesUpdateable fullModel, Instances trainingSet, java.util.Random r)
Utility method for fast 5-fold cross validation of a naive bayes modelDiscretize
getDiscretizer()
Return the discretizer used at this nodedouble
getErrors()
Return the errors made by the naive bayes model at this nodeNaiveBayesUpdateable
getNaiveBayesModel()
Get the naive bayes model at this nodejava.lang.String
getRevision()
Returns the revision string.java.lang.String
leftSide(Instances instances)
Does nothing because no condition has to be satisfied.java.lang.String
rightSide(int index, Instances instances)
Does nothing because no condition has to be satisfied.java.lang.String
sourceExpression(int index, Instances data)
Returns a string containing java source code equivalent to the test made at this node.java.lang.String
toString()
Return a textual description of the nodedouble[]
weights(Instance instance)
Always returns null because there is only one subset.int
whichSubset(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:
buildClassifier
in classClassifierSplitModel
- Parameters:
instances
- anInstances
value- 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
Discretize
value
-
getNaiveBayesModel
public NaiveBayesUpdateable getNaiveBayesModel()
Get the naive bayes model at this node- Returns:
- a
NaiveBayesUpdateable
value
-
whichSubset
public final int whichSubset(Instance instance)
Always returns 0 because only there is only one subset.- Specified by:
whichSubset
in classClassifierSplitModel
-
weights
public final double[] weights(Instance instance)
Always returns null because there is only one subset.- Specified by:
weights
in classClassifierSplitModel
-
leftSide
public final java.lang.String leftSide(Instances instances)
Does nothing because no condition has to be satisfied.- Specified by:
leftSide
in 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:
rightSide
in 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:
sourceExpression
in 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.Exception
Return the probability for a class value- Overrides:
classProb
in 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:
toString
in classjava.lang.Object
- Returns:
- a
String
value
-
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
- aNaiveBayesUpdateable
valuetrainingSet
- anInstances
valuer
- aRandom
value- Returns:
- a
double
value - Throws:
java.lang.Exception
- if an error occurs
-
getRevision
public java.lang.String getRevision()
Returns the revision string.- Returns:
- the revision
-
-