public double computeCostAndPrune() { double costS = getMDL(); if (isLeaf()) return costS + 1; double minCost1 = getLeftChild().computeCostAndPrune(); double minCost2 = getRightChild().computeCostAndPrune(); double costSplit = Math.log(m_gainRatio.getNumSplitPointsForBestFeature()) / GainRatio.log2; double minCostN = Math.min(costS+1, costSplit+1+minCost1+minCost2); if (Maths.almostEquals(minCostN, costS+1)) m_leftChild = m_rightChild = null; return minCostN; }
public double computeCostAndPrune() { double costS = getMDL(); if (isLeaf()) return costS + 1; double minCost1 = getLeftChild().computeCostAndPrune(); double minCost2 = getRightChild().computeCostAndPrune(); double costSplit = Math.log(m_gainRatio.getNumSplitPointsForBestFeature()) / GainRatio.log2; double minCostN = Math.min(costS+1, costSplit+1+minCost1+minCost2); if (Maths.almostEquals(minCostN, costS+1)) m_leftChild = m_rightChild = null; return minCostN; }
public double computeCostAndPrune() { double costS = getMDL(); if (isLeaf()) return costS + 1; double minCost1 = getLeftChild().computeCostAndPrune(); double minCost2 = getRightChild().computeCostAndPrune(); double costSplit = Math.log(m_gainRatio.getNumSplitPointsForBestFeature()) / GainRatio.log2; double minCostN = Math.min(costS+1, costSplit+1+minCost1+minCost2); if (Maths.almostEquals(minCostN, costS+1)) m_leftChild = m_rightChild = null; return minCostN; }
public void print(String prefix) if (isLeaf()) { int bestLabelIndex = getGainRatio().getBaseLabelDistribution().getBestIndex(); int numMajorityLabel = (int) (getGainRatio().getBaseLabelDistribution().value(bestLabelIndex) * getSize()); double threshold = getGainRatio().getMaxValuedThreshold(); System.out.print(prefix + "\"" + featName + "\" <= " + threshold + ":"); if (m_leftChild.isLeaf()) { int bestLabelIndex = m_leftChild.getGainRatio().getBaseLabelDistribution().getBestIndex(); int numMajorityLabel = (int) (m_leftChild.getGainRatio().getBaseLabelDistribution().value(bestLabelIndex) * m_leftChild.getSize()); if (m_rightChild.isLeaf()) { int bestLabelIndex = m_rightChild.getGainRatio().getBaseLabelDistribution().getBestIndex(); int numMajorityLabel = (int) (m_rightChild.getGainRatio().getBaseLabelDistribution().value(bestLabelIndex) * m_rightChild.getSize());
public void print(String prefix) if (isLeaf()) { int bestLabelIndex = getGainRatio().getBaseLabelDistribution().getBestIndex(); int numMajorityLabel = (int) (getGainRatio().getBaseLabelDistribution().value(bestLabelIndex) * getSize()); double threshold = getGainRatio().getMaxValuedThreshold(); System.out.print(prefix + "\"" + featName + "\" <= " + threshold + ":"); if (m_leftChild.isLeaf()) { int bestLabelIndex = m_leftChild.getGainRatio().getBaseLabelDistribution().getBestIndex(); int numMajorityLabel = (int) (m_leftChild.getGainRatio().getBaseLabelDistribution().value(bestLabelIndex) * m_leftChild.getSize()); if (m_rightChild.isLeaf()) { int bestLabelIndex = m_rightChild.getGainRatio().getBaseLabelDistribution().getBestIndex(); int numMajorityLabel = (int) (m_rightChild.getGainRatio().getBaseLabelDistribution().value(bestLabelIndex) * m_rightChild.getSize());
public void print(String prefix) if (isLeaf()) { int bestLabelIndex = getGainRatio().getBaseLabelDistribution().getBestIndex(); int numMajorityLabel = (int) (getGainRatio().getBaseLabelDistribution().value(bestLabelIndex) * getSize()); double threshold = getGainRatio().getMaxValuedThreshold(); System.out.print(prefix + "\"" + featName + "\" <= " + threshold + ":"); if (m_leftChild.isLeaf()) { int bestLabelIndex = m_leftChild.getGainRatio().getBaseLabelDistribution().getBestIndex(); int numMajorityLabel = (int) (m_leftChild.getGainRatio().getBaseLabelDistribution().value(bestLabelIndex) * m_leftChild.getSize()); if (m_rightChild.isLeaf()) { int bestLabelIndex = m_rightChild.getGainRatio().getBaseLabelDistribution().getBestIndex(); int numMajorityLabel = (int) (m_rightChild.getGainRatio().getBaseLabelDistribution().value(bestLabelIndex) * m_rightChild.getSize());
/** * Count the number of non-leaf descendant nodes */ public int getNumDescendants() { if (isLeaf()) return 0; int count = 0; if (! getLeftChild().isLeaf()) count += 1 + getLeftChild().getNumDescendants(); if (! getRightChild().isLeaf()) count += 1 + getRightChild().getNumDescendants(); return count; }
/** * Count the number of non-leaf descendant nodes */ public int getNumDescendants() { if (isLeaf()) return 0; int count = 0; if (! getLeftChild().isLeaf()) count += 1 + getLeftChild().getNumDescendants(); if (! getRightChild().isLeaf()) count += 1 + getRightChild().getNumDescendants(); return count; }
/** * Count the number of non-leaf descendant nodes */ public int getNumDescendants() { if (isLeaf()) return 0; int count = 0; if (! getLeftChild().isLeaf()) count += 1 + getLeftChild().getNumDescendants(); if (! getRightChild().isLeaf()) count += 1 + getRightChild().getNumDescendants(); return count; }