|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.knime.base.node.mine.decisiontree2.model.DecisionTreeNode
public abstract class DecisionTreeNode
The base abstract implementations of a node of a decision tree. Separate implementations for a leaf and a split node (abstract) exist.
| Constructor Summary | |
|---|---|
(package private) |
DecisionTreeNode()
Empty Constructor visible only within package. |
protected |
DecisionTreeNode(int nodeId,
DataCell majorityClass,
LinkedHashMap<DataCell,Double> classCounts)
Constructor of base class. |
protected |
DecisionTreeNode(Node xmlNode,
DataCellStringMapper mapper)
Constructor of base class. |
| Method Summary | |
|---|---|
protected void |
addColorToMap(Color col,
double weight)
Adds the given color to the color map. |
abstract void |
addCoveredColor(DataRow row,
DataTableSpec spec,
double weight)
Add colors for a row of values if they fall within a specific node/branch. |
abstract void |
addCoveredPattern(DataRow row,
DataTableSpec spec,
double weight)
Add patterns given as a row of values if they fall within a specific node. |
abstract boolean |
addNodeToTreeDepthFirst(DecisionTreeNode node,
int ix)
Add a new node to the tree structure based on a depth-first indexing strategy. |
abstract Enumeration<DecisionTreeNode> |
children()
|
HashMap<Color,Double> |
coveredColors()
|
abstract Set<RowKey> |
coveredPattern()
|
static DecisionTreeNode |
createNewNode(Node xmlNode,
DataCellStringMapper mapper)
Create new node from XML-information. |
static DecisionTreeNode |
createNodeFromPredictorParams(ModelContentRO predParams,
DecisionTreeNode parent)
Creates a new DecisionTreeNode (and all it's children!) based on an model content object. |
abstract boolean |
getAllowsChildren()
|
abstract DecisionTreeNode |
getChildAt(int pos)
|
abstract int |
getChildCount()
|
LinkedHashMap<DataCell,Double> |
getClassCounts()
Return class counts, that is how many patterns (also fractions of) for each class were encountered in this branch during training. |
abstract LinkedHashMap<DataCell,Double> |
getClassCounts(DataRow row,
DataTableSpec spec)
Determine class counts for a new pattern given as a row of values. |
abstract int |
getCountOfSubtree()
Returns the count of the subtree. |
Object |
getCustomData()
To get the custom data object. |
double |
getEntireClassCount()
Return number of patterns of all classes. |
abstract int |
getIndex(TreeNode node)
Returns the index of node in the receivers children. |
DataCell |
getMajorityClass()
Return majority class of this node. |
(package private) double |
getOverallColorCount()
|
double |
getOwnClassCount()
Return number of patterns of correct class (= majority class in a non-risk decision tree). |
int |
getOwnIndex()
|
DecisionTreeNode |
getParent()
|
String |
getPrefix()
Returns the prefix of this node representing the condition. |
abstract String |
getStringSummary()
|
Pair<DataCell,LinkedHashMap<DataCell,Double>> |
getWinnerAndClasscounts(DataRow row,
DataTableSpec spec)
Classify a new pattern given as a row of values. |
abstract boolean |
isLeaf()
|
void |
loadFromPredictorParams(ModelContentRO predParams)
Load node from a model content object. |
abstract void |
loadNodeInternalsFromPredParams(ModelContentRO pConf)
Load internal node settings from a model content object. |
(package private) boolean |
newColors()
|
void |
resetColorInformation()
Clean all color information in this node and all children. |
abstract void |
saveNodeInternalsToPredParams(ModelContentWO pConf,
boolean saveKeysAndPatterns)
Save internal node settings to a model content object. |
void |
saveToPredictorParams(ModelContentWO predParams,
boolean saveColorsAndKeys)
Save node to a model content object. |
void |
setCoveredColors(HashMap<Color,Double> coveredColors)
Sets the covered colors distribution directly. |
void |
setCustomData(Object customData)
To set a custom data object. |
void |
setParent(DecisionTreeNode parent)
Set parent of this node. |
void |
setPrefix(String pf)
Set information about this node, e.g. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
DecisionTreeNode()
protected DecisionTreeNode(Node xmlNode,
DataCellStringMapper mapper)
xmlNode - XML node objectmapper - map translating column names to DataCells and vice
versa
protected DecisionTreeNode(int nodeId,
DataCell majorityClass,
LinkedHashMap<DataCell,Double> classCounts)
nodeId - the id of this nodemajorityClass - the majority class of the records in this nodeclassCounts - the class distribution of the data in this node| Method Detail |
|---|
public static DecisionTreeNode createNewNode(Node xmlNode,
DataCellStringMapper mapper)
xmlNode - XML Information for this nodemapper - map translating column names to DataCells and vice
versa
public abstract boolean addNodeToTreeDepthFirst(DecisionTreeNode node,
int ix)
node - node to be insertedix - index of this node in depth first traversal order
public DataCell getMajorityClass()
public LinkedHashMap<DataCell,Double> getClassCounts()
public final Pair<DataCell,LinkedHashMap<DataCell,Double>> getWinnerAndClasscounts(DataRow row,
DataTableSpec spec)
throws Exception
row - input patternspec - the corresponding table spec
Exception - if something went wrong (unknown attribute for example)
public abstract LinkedHashMap<DataCell,Double> getClassCounts(DataRow row,
DataTableSpec spec)
row - input patternspec - the corresponding table spec
public double getOwnClassCount()
public double getEntireClassCount()
public abstract void addCoveredPattern(DataRow row,
DataTableSpec spec,
double weight)
throws Exception
row - input patternspec - the corresponding table specweight - the weight of the row (between 0.0 and 1.0)
Exception - if something went wrong (unknown attribute for example)
public abstract void addCoveredColor(DataRow row,
DataTableSpec spec,
double weight)
throws Exception
row - input patternspec - the corresponding table specweight - the weight of the row (between 0.0 and 1.0)
Exception - if something went wrong (unknown attribute for example)public abstract Set<RowKey> coveredPattern()
public final HashMap<Color,Double> coveredColors()
public void resetColorInformation()
boolean newColors()
public int getOwnIndex()
public void setParent(DecisionTreeNode parent)
parent - new parentdouble getOverallColorCount()
public final String toString()
toString in class Objectpublic void setPrefix(String pf)
pf - string describing conditionpublic abstract String getStringSummary()
public void saveToPredictorParams(ModelContentWO predParams,
boolean saveColorsAndKeys)
predParams - configuration object to attach decision tree tosaveColorsAndKeys - whether to save the colors and the row keys
public abstract void saveNodeInternalsToPredParams(ModelContentWO pConf,
boolean saveKeysAndPatterns)
pConf - configuration object to attach decision tree tosaveKeysAndPatterns - whether to save the keys and patterns
public void loadFromPredictorParams(ModelContentRO predParams)
throws InvalidSettingsException
predParams - configuration object to load decision tree from
InvalidSettingsException - if something goes wrong
public static DecisionTreeNode createNodeFromPredictorParams(ModelContentRO predParams,
DecisionTreeNode parent)
throws InvalidSettingsException
predParams - configuration objectparent - the parent node (or null if this is the
root)
InvalidSettingsException - if something goes wrong
public abstract void loadNodeInternalsFromPredParams(ModelContentRO pConf)
throws InvalidSettingsException
pConf - configuration object to load decision tree from
InvalidSettingsException - if something goes wrongpublic abstract int getChildCount()
getChildCount in interface TreeNodepublic abstract int getIndex(TreeNode node)
getIndex in interface TreeNodenode - that supposedly is a child of this one
public abstract DecisionTreeNode getChildAt(int pos)
getChildAt in interface TreeNodepos - position of child
public final DecisionTreeNode getParent()
getParent in interface TreeNodepublic abstract int getCountOfSubtree()
public abstract boolean isLeaf()
isLeaf in interface TreeNodetrue if node is a leafpublic abstract Enumeration<DecisionTreeNode> children()
children in interface TreeNodepublic abstract boolean getAllowsChildren()
getAllowsChildren in interface TreeNodetrue if the receiver allows childrenpublic String getPrefix()
protected void addColorToMap(Color col,
double weight)
col - the color to addweight - the weight for the color countpublic Object getCustomData()
public void setCustomData(Object customData)
customData - the custom data object to setpublic void setCoveredColors(HashMap<Color,Double> coveredColors)
coveredColors - the color distribution to set
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||