Package weka.classifiers.trees.j48

# Class NBTreeSplit

java.lang.Object
weka.classifiers.trees.j48.ClassifierSplitModel
weka.classifiers.trees.j48.NBTreeSplit

All Implemented Interfaces:
  `Serializable`, `Cloneable`, `RevisionHandler`

public class NBTreeSplit extends ClassifierSplitModel
Class implementing a NBTree split on an attribute.

Version:
  $Revision: 1.5 $
Author:
  Mark Hall (mhall@cs.waikato.ac.nz)
See Also:
  - Serialized Form

## Constructor Summary

Constructors
Constructor
Description
`NBTreeSplit(int attIndex, int minNoObj, double sumOfWeights)`
Initializes the split model.

## Method Summary

Modifier and Type
Method
Description
`final int`
`attIndex()`
Returns index of attribute for which split was generated.
`void`
`buildClassifier(Instances trainInstances)`
Creates a NBTree-type split on the given data.
`double`
`classProb(int classIndex, Instance instance, int theSubset)`
Return the probability for a class value
`double`
`getErrors()`
Return the errors made by the naive bayes models arising from this split.
`NBTreeNoSplit`
`getGlobalModel()`
Return the global naive bayes model for this node
`String`
`getRevision()`
Returns the revision string.
`final String`
`leftSide(Instances data)`
Prints left side of condition..
`final String`
`rightSide(int index, Instances data)`
Prints the condition satisfied by instances in a subset.
`void`
`setGlobalModel(NBTreeNoSplit global)`
Set the global naive bayes model for this node
`final String`
`sourceExpression(int index, Instances data)`
Returns a string containing java source code equivalent to the test made at this node.
`final double[]`
`weights(Instance instance)`
Returns weights if instance is assigned to more than one subset.
`final int`
`whichSubset(Instance instance)`
Returns index of subset instance is assigned to.

### Methods inherited from class weka.classifiers.trees.j48.ClassifierSplitModel

`checkModel, classifyInstance, classProbLaplace, clone, codingCost, distribution, dumpLabel, dumpModel, numSubsets, resetDistribution, sourceClass, split`

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### NBTreeSplit

public NBTreeSplit(int attIndex, int minNoObj, double sumOfWeights)
Initializes the split model.

## Method Details

### buildClassifier

public void buildClassifier(Instances trainInstances) throws Exception
Creates a NBTree-type split on the given data. Assumes that none of the class values is missing.

Specified by:
  `buildClassifier` in class `ClassifierSplitModel`
Throws:
  `Exception` - if something goes wrong

### attIndex

public final int attIndex()
Returns index of attribute for which split was generated.

### whichSubset

public final int whichSubset(Instance instance) throws Exception
Returns index of subset instance is assigned to. Returns -1 if instance is assigned to more than one subset.

Specified by:
  `whichSubset` in class `ClassifierSplitModel`
Throws:
  `Exception` - if something goes wrong

### weights

public final double[] weights(Instance instance)
Returns weights if instance is assigned to more than one subset. Returns null if instance is only assigned to one subset.

Specified by:
  `weights` in class `ClassifierSplitModel`

### sourceExpression

public final 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 class `ClassifierSplitModel`
Parameters:
  `index` - index of the nominal value tested
  `data` - the data containing instance structure info
Returns:
  a value of type 'String'

### rightSide

public final String rightSide(int index, Instances data)
Prints the condition satisfied by instances in a subset.

Specified by:
  `rightSide` in class `ClassifierSplitModel`
Parameters:
  `index` - of subset
  `data` - training set.

### leftSide

public final String leftSide(Instances data)
Prints left side of condition..

Specified by:
  `leftSide` in class `ClassifierSplitModel`
Parameters:
  `data` - training set.

### classProb

public double classProb(int classIndex, Instance instance, int theSubset) throws Exception
Return the probability for a class value

Overrides:
  `classProb` in class `ClassifierSplitModel`
Parameters:
  `classIndex` - the index of the class value
  `instance` - the instance to generate a probability for
  `theSubset` - the subset to consider
Returns:
  a probability
Throws:
  `Exception` - if an error occurs

### getGlobalModel

public NBTreeNoSplit getGlobalModel()
Return the global naive bayes model for this node

Returns:
  a `NBTreeNoSplit` value

### setGlobalModel

public void setGlobalModel(NBTreeNoSplit global)
Set the global naive bayes model for this node

Parameters:
  `global` - a `NBTreeNoSplit` value

### getErrors

public double getErrors()
Return the errors made by the naive bayes models arising from this split.

Returns:
  a `double` value

### getRevision

public String getRevision()
Returns the revision string.

Returns:
  the revision