Package org.apache.mahout.classifier.df.node

Examples of org.apache.mahout.classifier.df.node.CategoricalNode


        children[index] = build(rng, subsets[index]);
      }

      selected[best.getAttr()] = alreadySelected;

      childNode = new CategoricalNode(best.getAttr(), values, children);
    }

    return childNode;
  }
View Full Code Here


   
    StringBuilder buff = new StringBuilder();
   
    try {
      if (node instanceof CategoricalNode) {
        CategoricalNode cnode = (CategoricalNode) node;
        int attr = (Integer) fields.get("CategoricalNode.attr").get(cnode);
        double[] values = (double[]) fields.get("CategoricalNode.values").get(cnode);
        Node[] childs = (Node[]) fields.get("CategoricalNode.childs").get(cnode);
        String[][] attrValues = (String[][]) fields.get("Dataset.values").get(dataset);
        for (int i = 0; i < attrValues[attr].length; i++) {
View Full Code Here

      Dataset dataset, String[] attrNames, Map<String,Field> fields) {
    StringBuilder buff = new StringBuilder();
   
    try {
      if (node instanceof CategoricalNode) {
        CategoricalNode cnode = (CategoricalNode) node;
        int attr = (Integer) fields.get("CategoricalNode.attr").get(cnode);
        double[] values = (double[]) fields.get("CategoricalNode.values").get(
            cnode);
        Node[] childs = (Node[]) fields.get("CategoricalNode.childs")
            .get(cnode);
View Full Code Here

        children[index] = build(rng, subsets[index]);
      }

      selected[best.getAttr()] = alreadySelected;

      childNode = new CategoricalNode(best.getAttr(), values, children);
    }

    return childNode;
  }
View Full Code Here

        children[index] = build(rng, subset);
      }

      selected[best.getAttr()] = alreadySelected;

      childNode = new CategoricalNode(best.getAttr(), values, children);
    }

    return childNode;
  }
View Full Code Here

 
  @Test
  public void testForestVisualize() throws Exception {
    // Tree
    NumericalNode root = new NumericalNode(2, 90, new Leaf(0),
        new CategoricalNode(0, new double[] {0, 1, 2}, new Node[] {
            new NumericalNode(1, 71, new Leaf(0), new Leaf(1)), new Leaf(1),
            new Leaf(0)}));
    List<Node> trees = Lists.newArrayList();
    trees.add(root);
   
View Full Code Here

  private static String toStringNode(Node node, Dataset dataset, String[] attrNames,
    Map<String, Field> fields, int layer) throws IllegalAccessException {
    StringBuilder buff = new StringBuilder();

    if (node instanceof CategoricalNode) {
      CategoricalNode cnode = (CategoricalNode) node;
      int attr = (Integer) fields.get("CategoricalNode.attr").get(cnode);
      double[] values = (double[]) fields.get("CategoricalNode.values").get(cnode);
      Node[] childs = (Node[]) fields.get("CategoricalNode.childs").get(cnode);
      String[][] attrValues = (String[][]) fields.get("Dataset.values").get(dataset);
      for (int i = 0; i < childs.length; i++) {
View Full Code Here

  private static String toStringPredict(Node node, Instance instance, Dataset dataset,
    String[] attrNames, Map<String, Field> fields) throws IllegalAccessException {
    StringBuilder buff = new StringBuilder();

    if (node instanceof CategoricalNode) {
      CategoricalNode cnode = (CategoricalNode) node;
      int attr = (Integer) fields.get("CategoricalNode.attr").get(cnode);
      double[] values = (double[]) fields.get("CategoricalNode.values").get(cnode);
      Node[] childs = (Node[]) fields.get("CategoricalNode.childs").get(cnode);
      String[][] attrValues = (String[][]) fields.get("Dataset.values").get(dataset);
View Full Code Here

        children[index] = build(rng, subsets[index]);
      }

      selected[best.getAttr()] = alreadySelected;

      childNode = new CategoricalNode(best.getAttr(), values, children);
    }

    return childNode;
  }
View Full Code Here

 
  @Test
  public void testForestVisualize() throws Exception {
    // Tree
    NumericalNode root = new NumericalNode(2, 90, new Leaf(0),
      new CategoricalNode(0, new double[] {0, 1, 2}, new Node[] {
        new NumericalNode(1, 71, new Leaf(0), new Leaf(1)), new Leaf(1),
        new Leaf(0)}));
    List<Node> trees = new ArrayList<Node>();
    trees.add(root);
   
View Full Code Here

TOP

Related Classes of org.apache.mahout.classifier.df.node.CategoricalNode

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.