Package org.apache.mahout.df.node

Examples of org.apache.mahout.df.node.Node


        best = split;
    }

    if (data.getDataset().isNumerical(best.attr)) {
      Data loSubset = data.subset(Condition.lesser(best.attr, best.split));
      Node loChild = build(rng, loSubset);

      Data hiSubset = data.subset(Condition.greaterOrEquals(best.attr,
          best.split));
      Node hiChild = build(rng, hiSubset);

      return new NumericalNode(best.attr, best.split, loChild, hiChild);
    } else { // CATEGORICAL attribute
      double[] values = data.values(best.attr);
      Node[] childs = new Node[values.length];
View Full Code Here


    }

    initRandom((InMemInputSplit)context.getInputSplit());

    log.debug("Building...");
    Node tree = bagging.build(key.get(), rng, callback);

    if (!isNoOutput()) {
      log.debug("Outputing...");
      MapredOutput mrOut = new MapredOutput(tree, predictions);
View Full Code Here

    }

    initRandom(split);

    log.debug("Building...");
    Node tree = bagging.build(key.get(), rng, callback);

    if (!isNoOutput()) {
      log.debug("Outputing...");
      MapredOutput mrOut = new MapredOutput(tree, predictions);
View Full Code Here

      if (isOobEstimate() && !isNoOutput()) {
        callback = new SingleTreePredictions(data.size());
        predictions = callback.getPredictions();
      }

      Node tree = bagging.build(treeId, rng, callback);

      key.set(partition, firstTreeId + treeId);

      if (!isNoOutput()) {
        MapredOutput emOut = new MapredOutput(tree, predictions);
View Full Code Here

      partitions.add(partition);

      int nbTrees = Step1Mapper.nbTrees(numMaps, numTrees, partition);

      for (int treeId = 0; treeId < nbTrees; treeId++) {
        Node tree = new Leaf(rng.nextInt(100));

        keys[index] = new TreeID(partition, treeId);
        values[index] = new MapredOutput(tree, nextIntArray(rng, numInstances));

        index++;
View Full Code Here

      partitions.add(partition);

      int nbTrees = Step1Mapper.nbTrees(numMaps, numTrees, partition);

      for (int treeId = 0; treeId < nbTrees; treeId++) {
        Node tree = new Leaf(rng.nextInt(100));

        keys[index] = new TreeID(partition, treeId);
        values[index] = new MapredOutput(tree, nextIntArray(rng, numInstances));

        index++;
View Full Code Here

      // load (key, tree)
      TreeID key = new TreeID();
      for (int index = 0; index < nbTrees; index++) {
        key.readFields(in);
        Node value = Node.read(in);

        assertEquals("index: " + index, keys[index], key);
        assertEquals("index: " + index, trees[index], value);
      }
    } finally {
View Full Code Here

    if (data.isEmpty()) {
      return; // nothing to classify
    }

    for (int treeId = 0; treeId < trees.size(); treeId++) {
      Node tree = trees.get(treeId);

      for (int index = 0; index < data.size(); index++) {
        int prediction = tree.classify(data.get(index));
        callback.prediction(treeId, index, prediction);
      }
    }
  }
View Full Code Here

    if (alreadySelected) {
      // attribute already selected
      log.warn("attribute {} already selected in a parent node", best.getAttr());
    }
   
    Node childNode;
    if (data.getDataset().isNumerical(best.getAttr())) {
      boolean[] temp = null;

      Data loSubset = data.subset(Condition.lesser(best.getAttr(), best.getSplit()));
      Data hiSubset = data.subset(Condition.greaterOrEquals(best.getAttr(), best.getSplit()));

      if (loSubset.isEmpty() || hiSubset.isEmpty()) {
        // the selected attribute did not change the data, avoid using it in the child notes
        selected[best.getAttr()] = true;
      } else {
        // the data changed, so we can unselect all previousely selected NUMERICAL attributes
        temp = selected;
        selected = cloneCategoricalAttributes(data.getDataset(), selected);
      }

      Node loChild = build(rng, loSubset);
      Node hiChild = build(rng, hiSubset);

      // restore the selection state of the attributes
      if (temp != null) {
        selected = temp;
      } else {
View Full Code Here

TOP

Related Classes of org.apache.mahout.df.node.Node

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.