public class LMTNode extends LogisticBase
| Modifier and Type | Field and Description |
|---|---|
double |
m_alpha
Alpha-value (for pruning) at the node
|
protected boolean |
m_fastRegression
Use heuristic that determines the number of LogitBoost iterations only once in the beginning?
|
protected int |
m_id
Node id
|
protected boolean |
m_isLeaf
True if node is leaf
|
protected int |
m_leafModelNum
ID of logistic model at leaf
|
protected ClassifierSplitModel |
m_localModel
The ClassifierSplitModel (for splitting)
|
protected int |
m_minNumInstances
minimum number of instances at which a node is considered for splitting
|
protected ModelSelection |
m_modelSelection
ModelSelection object (for splitting)
|
protected NominalToBinary |
m_nominalToBinary
Filter to convert nominal attributes to binary
|
protected static int |
m_numFoldsPruning
Number of folds for CART pruning
|
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
|
protected int |
m_numInstances
Number of instances at the node
|
protected LMTNode[] |
m_sons
Array of children of the node
|
protected double |
m_totalInstanceWeight
Total number of training instances.
|
m_errorOnProbabilities, m_fixedNumIterations, m_heuristicStop, m_maxIterations, m_numClasses, m_numericData, m_numericDataHeader, m_numFoldsBoosting, m_numParameters, m_numRegressions, m_regressions, m_train, m_useCrossValidation, m_weightTrimBeta, Z_MAXBATCH_SIZE_DEFAULT, m_BatchSize, m_Debug, m_DoNotCheckCapabilities, m_numDecimalPlaces, NUM_DECIMAL_PLACES_DEFAULT| Constructor and Description |
|---|
LMTNode(ModelSelection modelSelection,
int numBoostingIterations,
boolean fastRegression,
boolean errorOnProbabilities,
int minNumInstances,
double weightTrimBeta,
boolean useAIC,
NominalToBinary ntb,
int numDecimalPlaces)
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,
Instances numericDataHeader)
Method for building the tree structure.
|
void |
calculateAlphas()
Updates the alpha field for all nodes.
|
double[] |
distributionForInstance(Instance instance)
Returns the class probabilities for an instance given by the logistic model tree.
|
protected void |
dumpTree(int depth,
java.lang.StringBuffer text)
Help method for printing tree structure.
|
java.lang.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.
|
java.util.Vector<LMTNode> |
getNodes()
Return a list of all inner nodes in the tree
|
void |
getNodes(java.util.Vector<LMTNode> nodeList)
Fills a list with all inner nodes in the tree
|
protected Instances |
getNumericData(Instances train)
Returns a numeric version of a set of instances.
|
int |
getNumInnerNodes()
Method to count the number of inner nodes in the tree
|
int |
getNumLeaves()
Returns the number of leaves in the tree.
|
java.lang.String |
getRevision()
Returns the revision string.
|
java.lang.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.
|
java.lang.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.
|
java.lang.String |
toString()
Returns a description of the logistic model tree (tree structure and logistic models)
|
void |
treeErrors()
Updates the numIncorrectTree field for all nodes.
|
protected int |
tryLogistic(Instances data)
Determines the optimum number of LogitBoost iterations to perform by building a standalone
logistic regression function on the training data.
|
protected void |
unprune()
Method to "unprune" a logistic model tree.
|
cleanup, copyRegressions, getBestIteration, getCoefficients, getErrorRate, getFs, getFs, getMaxIterations, getMeanAbsoluteError, getNumRegressions, getProbs, getUseAIC, getUsedAttributes, getWeightTrimBeta, getWs, getYs, getZ, getZs, initRegressions, negativeLogLikelihood, percentAttributesUsed, performBoosting, performBoosting, performBoosting, performBoostingCV, performBoostingInfCriterion, performIteration, probs, setHeuristicStop, setMaxIterations, setUseAIC, setWeightTrimBetabatchSizeTipText, classifyInstance, debugTipText, distributionsForInstances, doNotCheckCapabilitiesTipText, forName, getBatchSize, getCapabilities, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, getOptions, implementsMoreEfficientBatchPrediction, listOptions, makeCopies, makeCopy, numDecimalPlacesTipText, postExecution, preExecution, run, runClassifier, setBatchSize, setDebug, setDoNotCheckCapabilities, setNumDecimalPlaces, setOptionsprotected double m_totalInstanceWeight
protected int m_id
protected int m_leafModelNum
public double m_alpha
public double m_numIncorrectModel
public double m_numIncorrectTree
protected int m_minNumInstances
protected ModelSelection m_modelSelection
protected NominalToBinary m_nominalToBinary
protected static int m_numFoldsPruning
protected boolean m_fastRegression
protected int m_numInstances
protected ClassifierSplitModel m_localModel
protected LMTNode[] m_sons
protected boolean m_isLeaf
public LMTNode(ModelSelection modelSelection, int numBoostingIterations, boolean fastRegression, boolean errorOnProbabilities, int minNumInstances, double weightTrimBeta, boolean useAIC, NominalToBinary ntb, int numDecimalPlaces)
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 java.lang.Exception
buildClassifier in interface ClassifierbuildClassifier in class LogisticBasedata - the data to train withjava.lang.Exception - if something goes wrongpublic void buildTree(Instances data, SimpleLinearRegression[][] higherRegressions, double totalInstanceWeight, double higherNumParameters, Instances numericDataHeader) throws java.lang.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 nodesjava.lang.Exception - if something goes wrongpublic void prune(double alpha)
throws java.lang.Exception
alpha - the cost-complexity measurejava.lang.Exception - if something goes wrongpublic int prune(double[] alphas,
double[] errors,
Instances test)
throws java.lang.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)java.lang.Exception - if something goes wrongprotected void unprune()
protected int tryLogistic(Instances data) throws java.lang.Exception
data - training instances for the logistic modeljava.lang.Exception - if something goes wrongpublic int getNumInnerNodes()
public int getNumLeaves()
public void treeErrors()
public void calculateAlphas()
throws java.lang.Exception
java.lang.Exceptionpublic java.util.Vector<LMTNode> getNodes()
public void getNodes(java.util.Vector<LMTNode> nodeList)
nodeList - the list to be filledprotected Instances getNumericData(Instances train) throws java.lang.Exception
getNumericData in class LogisticBasetrain - the data to convertjava.lang.Exception - if something goes wrongpublic boolean hasModels()
public double[] modelDistributionForInstance(Instance instance) throws java.lang.Exception
instance - the instancejava.lang.Exceptionpublic double[] distributionForInstance(Instance instance) throws java.lang.Exception
distributionForInstance in interface ClassifierdistributionForInstance in class LogisticBaseinstance - the instancejava.lang.Exception - if distribution can't be computed successfullypublic int numLeaves()
public int numNodes()
public java.lang.String toString()
toString in class LogisticBasepublic java.lang.String getModelParameters()
protected void dumpTree(int depth,
java.lang.StringBuffer text)
throws java.lang.Exception
java.lang.Exception - if something goes wrongpublic int assignIDs(int lastID)
public int assignLeafModelNumbers(int leafCounter)
public java.lang.String modelsToString()
public java.lang.String graph()
throws java.lang.Exception
java.lang.Exception - if something goes wrongpublic java.lang.String getRevision()
getRevision in interface RevisionHandlergetRevision in class LogisticBase