Package weka.classifiers.trees.adtree

Examples of weka.classifiers.trees.adtree.Splitter


  private void goDownAllPathsSingle(PredictionNode currentNode,
            Instances posInstances, Instances negInstances)
    throws Exception {

    for (Enumeration e = currentNode.children(); e.hasMoreElements(); ) {
      Splitter split = (Splitter) e.nextElement();
      for (int i=0; i<split.getNumOfBranches(); i++)
  searchForBestTestSingle(split.getChildForBranch(i),
        split.instancesDownBranch(i, posInstances),
        split.instancesDownBranch(i, negInstances));
    }
  }
View Full Code Here


   */
  private void goDownHeaviestPathSingle(PredictionNode currentNode,
          Instances posInstances, Instances negInstances)
    throws Exception {

    Splitter heaviestSplit = null;
    int heaviestBranch = 0;
    double largestWeight = 0.0;
    for (Enumeration e = currentNode.children(); e.hasMoreElements(); ) {
      Splitter split = (Splitter) e.nextElement();
      for (int i=0; i<split.getNumOfBranches(); i++) {
  double weight =
    split.instancesDownBranch(i, posInstances).sumOfWeights() +
    split.instancesDownBranch(i, negInstances).sumOfWeights();
  if (weight > largestWeight) {
    heaviestSplit = split;
    heaviestBranch = i;
    largestWeight = weight;
  }
View Full Code Here

    PredictionNode bestPath = null;
    Instances bestPosSplit = null, bestNegSplit = null;

    // search for branch with lowest Z-pure
    for (Enumeration e = currentNode.children(); e.hasMoreElements(); ) {
      Splitter split = (Splitter) e.nextElement();
      for (int i=0; i<split.getNumOfBranches(); i++) {
  Instances posSplit = split.instancesDownBranch(i, posInstances);
  Instances negSplit = split.instancesDownBranch(i, negInstances);
  double newZpure = calcZpure(posSplit, negSplit);
  if (newZpure < lowestZpure) {
    lowestZpure = newZpure;
    bestPath = split.getChildForBranch(i);
    bestPosSplit = posSplit;
    bestNegSplit = negSplit;
  }
      }
    }
View Full Code Here

  private void goDownRandomPathSingle(PredictionNode currentNode,
              Instances posInstances, Instances negInstances)
    throws Exception {

    FastVector children = currentNode.getChildren();
    Splitter split = (Splitter) children.elementAt(getRandom(children.size()));
    int branch = getRandom(split.getNumOfBranches());
    searchForBestTestSingle(split.getChildForBranch(branch),
          split.instancesDownBranch(branch, posInstances),
          split.instancesDownBranch(branch, negInstances));
  }
View Full Code Here

  protected double predictionValueForInstance(Instance inst, PredictionNode currentNode,
              double currentValue) {
   
    currentValue += currentNode.getValue();
    for (Enumeration e = currentNode.children(); e.hasMoreElements(); ) {
      Splitter split = (Splitter) e.nextElement();
      int branch = split.branchInstanceGoesDown(inst);
      if (branch >= 0)
  currentValue = predictionValueForInstance(inst, split.getChildForBranch(branch),
              currentValue);
    }
    return currentValue;
  }
View Full Code Here

    StringBuffer text = new StringBuffer();
   
    text.append(": " + Utils.doubleToString(currentNode.getValue(),3));
   
    for (Enumeration e = currentNode.children(); e.hasMoreElements(); ) {
      Splitter split = (Splitter) e.nextElement();
     
      for (int j=0; j<split.getNumOfBranches(); j++) {
  PredictionNode child = split.getChildForBranch(j);
  if (child != null) {
    text.append("\n");
    for (int k = 0; k < level; k++) {
      text.append("|  ");
    }
    text.append("(" + split.orderAdded + ")");
    text.append(split.attributeString(m_trainInstances) + " "
          + split.comparisonString(j, m_trainInstances));
    text.append(toString(child, level + 1));
  }
      }
    }
    return text.toString();
View Full Code Here

      text.append(" (" + legend() + ")");
    text.append("\" shape=box style=filled");
    if (instances.numInstances() > 0) text.append(" data=\n" + instances + "\n,\n");
    text.append("]\n");
    for (Enumeration e = currentNode.children(); e.hasMoreElements(); ) {
      Splitter split = (Splitter) e.nextElement();
      text.append("S" + splitOrder + "P" + predOrder + "->" + "S" + split.orderAdded +
      " [style=dotted]\n");
      text.append("S" + split.orderAdded + " [label=\"" + split.orderAdded + ": " +
      split.attributeString(m_trainInstances) + "\"]\n");

      for (int i=0; i<split.getNumOfBranches(); i++) {
  PredictionNode child = split.getChildForBranch(i);
  if (child != null) {
    text.append("S" + split.orderAdded + "->" + "S" + split.orderAdded + "P" + i +
          " [label=\"" + split.comparisonString(i, m_trainInstances) + "\"]\n");
    graphTraverse(child, text, split.orderAdded, i,
      split.instancesDownBranch(i, instances));
  }
      }
    } 
  }
View Full Code Here

    int numSoFar = 0;
    if (root != null) {
      numSoFar++;
      for (Enumeration e = root.children(); e.hasMoreElements(); ) {
  numSoFar++;
  Splitter split = (Splitter) e.nextElement();
  for (int i=0; i<split.getNumOfBranches(); i++)
      numSoFar += numOfAllNodes(split.getChildForBranch(i));
      }
    }
    return numSoFar;
  }
View Full Code Here

   
    int numSoFar = 0;
    if (root != null) {
      numSoFar++;
      for (Enumeration e = root.children(); e.hasMoreElements(); ) {
  Splitter split = (Splitter) e.nextElement();
  for (int i=0; i<split.getNumOfBranches(); i++)
      numSoFar += numOfPredictionNodes(split.getChildForBranch(i));
      }
    }
    return numSoFar;
  }
View Full Code Here

  protected int numOfPredictionLeafNodes(PredictionNode root) {
   
    int numSoFar = 0;
    if (root.getChildren().size() > 0) {
      for (Enumeration e = root.children(); e.hasMoreElements(); ) {
  Splitter split = (Splitter) e.nextElement();
  for (int i=0; i<split.getNumOfBranches(); i++)
      numSoFar += numOfPredictionLeafNodes(split.getChildForBranch(i));
      }
    } else numSoFar = 1;
    return numSoFar;
  }
View Full Code Here

TOP

Related Classes of weka.classifiers.trees.adtree.Splitter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.