Package org.apache.mahout.df.node

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


    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


      // load (key, tree)
      TreeID key = new TreeID();
      for (int index = 0; index < NUM_TREES; 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

      partitions.add(partition);

      int nbTrees = Step1Mapper.nbTrees(NUM_MAPS, NUM_TREES, 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, NUM_INSTANCES));

        index++;
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

    if (alreadySelected) {
      // attribute already selected
      log.warn("attribute {} already selected in a parent node", best.getAttr());
    }
   
    Node childNode;
    if (data.getDataset().isNumerical(best.getAttr())) {
      Data loSubset = data.subset(Condition.lesser(best.getAttr(), best.getSplit()));
      Node loChild = build(rng, loSubset);
     
      Data hiSubset = data.subset(Condition.greaterOrEquals(best.getAttr(), best.getSplit()));
      Node hiChild = build(rng, hiSubset);
     
      childNode = new NumericalNode(best.getAttr(), best.getSplit(), loChild, hiChild);
    } else { // CATEGORICAL attribute
      selected[best.getAttr()] = true;
     
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

    log.debug("Bagging...");
    Arrays.fill(sampled, false);
    Data bag = data.bagging(rng, sampled);

    log.debug("Building...");
    Node tree = treeBuilder.build(rng, bag);

    // predict the label for the out-of-bag elements
    if (callback != null) {
      log.debug("Oob error estimation");
      for (int index = 0; index < data.size(); index++) {
        if (sampled[index] == false) {
          int prediction = tree.classify(data.get(index));
          callback.prediction(treeId, index, prediction);
        }
      }
    }
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 (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

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.