public class LMTNode extends LogisticBase
Modifier and Type | Field and Description |
---|---|
double |
m_alpha
Alpha-value (for pruning) at the node
|
double |
m_numIncorrectModel
Weighted number of training examples currently misclassified by the logistic model at the node
|
double |
m_numIncorrectTree
Weighted number of training examples currently misclassified by the subtree rooted at the node
|
Constructor and Description |
---|
LMTNode(ModelSelection modelSelection,
int numBoostingIterations,
boolean fastRegression,
boolean errorOnProbabilities,
int minNumInstances,
double weightTrimBeta,
boolean useAIC)
Constructor for logistic model tree node.
|
Modifier and Type | Method and Description |
---|---|
int |
assignIDs(int lastID)
Assigns unique IDs to all nodes in the tree
|
int |
assignLeafModelNumbers(int leafCounter)
Assigns numbers to the logistic regression models at the leaves of the tree
|
void |
buildClassifier(Instances data)
Method for building a logistic model tree (only called for the root node).
|
void |
buildTree(Instances data,
SimpleLinearRegression[][] higherRegressions,
double totalInstanceWeight,
double higherNumParameters)
Method for building the tree structure.
|
void |
calculateAlphas()
Updates the alpha field for all nodes.
|
void |
cleanup()
Cleanup in order to save memory.
|
double[] |
distributionForInstance(Instance instance)
Returns the class probabilities for an instance given by the logistic model tree.
|
String |
getModelParameters()
Returns a string describing the number of LogitBoost iterations performed at this node, the total number
of LogitBoost iterations performed (including iterations at higher levels in the tree), and the number
of training examples at this node.
|
Vector |
getNodes()
Return a list of all inner nodes in the tree
|
void |
getNodes(Vector nodeList)
Fills a list with all inner nodes in the tree
|
int |
getNumInnerNodes()
Method to count the number of inner nodes in the tree
|
int |
getNumLeaves()
Returns the number of leaves in the tree.
|
String |
getRevision()
Returns the revision string.
|
String |
graph()
Returns graph describing the tree.
|
boolean |
hasModels()
Returns true if the logistic regression model at this node has changed compared to the
one at the parent node.
|
double[] |
modelDistributionForInstance(Instance instance)
Returns the class probabilities for an instance according to the logistic model at the node.
|
void |
modelErrors()
Updates the numIncorrectModel field for all nodes.
|
String |
modelsToString()
Returns a string describing the logistic regression function at the node.
|
int |
numLeaves()
Returns the number of leaves (normal count).
|
int |
numNodes()
Returns the number of nodes.
|
void |
prune(double alpha)
Prunes a logistic model tree using the CART pruning scheme, given a
cost-complexity parameter alpha.
|
int |
prune(double[] alphas,
double[] errors,
Instances test)
Method for performing one fold in the cross-validation of the cost-complexity parameter.
|
String |
toString()
Returns a description of the logistic model tree (tree structure and logistic models)
|
void |
treeErrors()
Updates the numIncorrectTree field for all nodes.
|
getMaxIterations, getNumRegressions, getUseAIC, getUsedAttributes, getWeightTrimBeta, percentAttributesUsed, setHeuristicStop, setMaxIterations, setUseAIC, setWeightTrimBeta
classifyInstance, debugTipText, forName, getCapabilities, getDebug, getOptions, listOptions, makeCopies, makeCopy, runClassifier, setDebug, setOptions
public double m_alpha
public double m_numIncorrectModel
public double m_numIncorrectTree
public LMTNode(ModelSelection modelSelection, int numBoostingIterations, boolean fastRegression, boolean errorOnProbabilities, int minNumInstances, double weightTrimBeta, boolean useAIC)
modelSelection
- selection method for local splitting modelnumBoostingIterations
- sets the numBoostingIterations parameterfastRegression
- sets the fastRegression parametererrorOnProbabilities
- Use error on probabilities for stopping criterion of LogitBoost?minNumInstances
- minimum number of instances at which a node is considered for splittingpublic void buildClassifier(Instances data) throws Exception
buildClassifier
in interface Classifier
buildClassifier
in class LogisticBase
data
- the data to train withException
- if something goes wrongpublic void buildTree(Instances data, SimpleLinearRegression[][] higherRegressions, double totalInstanceWeight, double higherNumParameters) throws Exception
data
- the training data passed on to this nodehigherRegressions
- An array of regression functions produced by LogitBoost at higher
levels in the tree. They represent a logistic regression model that is refined locally
at this node.totalInstanceWeight
- the total number of training exampleshigherNumParameters
- effective number of parameters in the logistic regression model built
in parent nodesException
- if something goes wrongpublic void prune(double alpha) throws Exception
alpha
- the cost-complexity measureException
- if something goes wrongpublic int prune(double[] alphas, double[] errors, Instances test) throws Exception
alphas
- array to hold the generated alpha-valueserrors
- array to hold the corresponding error estimatestest
- test set of that fold (to obtain error estimates)Exception
- if something goes wrongpublic int getNumInnerNodes()
public int getNumLeaves()
public void modelErrors() throws Exception
Exception
public void treeErrors()
public void calculateAlphas() throws Exception
Exception
public Vector getNodes()
public void getNodes(Vector nodeList)
nodeList
- the list to be filledpublic boolean hasModels()
public double[] modelDistributionForInstance(Instance instance) throws Exception
instance
- the instanceException
public double[] distributionForInstance(Instance instance) throws Exception
distributionForInstance
in interface Classifier
distributionForInstance
in class LogisticBase
instance
- the instanceException
- if distribution can't be computed successfullypublic int numLeaves()
public int numNodes()
public String toString()
toString
in class LogisticBase
public String getModelParameters()
public int assignIDs(int lastID)
public int assignLeafModelNumbers(int leafCounter)
public String modelsToString()
public String graph() throws Exception
Exception
- if something goes wrongpublic void cleanup()
cleanup
in class LogisticBase
public String getRevision()
getRevision
in interface RevisionHandler
getRevision
in class LogisticBase
Copyright © 2012 University of Waikato, Hamilton, NZ. All Rights Reserved.