Package org.apache.mahout.df.data

Examples of org.apache.mahout.df.data.Instance


        first = false;
      }

      String line = value.toString();
      if (!line.isEmpty()) {
        Instance instance = converter.convert(0, line);
        int prediction = forest.classify(rng, instance);
        key.set(instance.getLabel());
        lvalue.set(Integer.toString(prediction));
        context.write(key, lvalue);
      }
    }
View Full Code Here


  private boolean isIdentical(Data data) {
    if (data.isEmpty()) {
      return true;
    }
   
    Instance instance = data.get(0);
    for (int attr = 0; attr < selected.length; attr++) {
      if (selected[attr]) {
        continue;
      }
     
      for (int index = 1; index < data.size(); index++) {
        if (data.get(index).get(attr) != instance.get(attr)) {
          return false;
        }
      }
    }
   
View Full Code Here

    int[][] counts = new int[values.length][data.getDataset().nblabels()];
    int[] countAll = new int[data.getDataset().nblabels()];
   
    // compute frequencies
    for (int index = 0; index < data.size(); index++) {
      Instance instance = data.get(index);
      counts[ArrayUtils.indexOf(values, instance.get(attr))][instance.getLabel()]++;
      countAll[instance.getLabel()]++;
    }
   
    int size = data.size();
    double hy = entropy(countAll, size); // H(Y)
    double hyx = 0.0; // H(Y|X)
View Full Code Here

    countLess = new int[data.getDataset().nblabels()];
  }
 
  protected void computeFrequencies(Data data, int attr, double[] values) {
    for (int index = 0; index < data.size(); index++) {
      Instance instance = data.get(index);
      counts[ArrayUtils.indexOf(values, instance.get(attr))][instance.getLabel()]++;
      countAll[instance.getLabel()]++;
    }
  }
View Full Code Here

      if (line.isEmpty()) {
        continue; // skip empty lines
      }
     
      // write the tuple in files[tuple.label]
      Instance instance = converter.convert(id++, line);
      int label = instance.getLabel();
      files[currents[label]].writeBytes(line);
      files[currents[label]].writeChar('\n');
     
      // update currents
      currents[label]++;
View Full Code Here

 
  @Override
  protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {

    Instance instance = converter.convert(instanceId, value.toString());

    for (int index = 0; index < keys.length; index++) {
      int prediction = trees[index].classify(instance);
      callbacks[index].prediction(index, instanceId, prediction);
    }
View Full Code Here

      throws IOException {
    if (this.output == null) {
      this.output = output;
    }

    Instance instance = converter.convert(instanceId, value.toString());

    for (int index = 0; index < keys.length; index++) {
      int prediction = trees[index].classify(instance);
      callbacks[index].prediction(index, instanceId, prediction);
    }
View Full Code Here

    int[][] counts = new int[values.length][data.getDataset().nblabels()];
    int[] countAll = new int[data.getDataset().nblabels()];

    // compute frequencies
    for (int index = 0; index < data.size(); index++) {
      Instance instance = data.get(index);
      counts[ArrayUtils.indexOf(values, instance.get(attr))][instance.label]++;
      countAll[instance.label]++;
    }

    int size = data.size();
    double hy = entropy(countAll, size); // H(Y)
View Full Code Here

    countLess = new int[data.getDataset().nblabels()];
  }

  protected void computeFrequencies(Data data, int attr, double[] values) {
    for (int index = 0; index < data.size(); index++) {
      Instance instance = data.get(index);
      counts[ArrayUtils.indexOf(values, instance.get(attr))][instance.label]++;
      countAll[instance.label]++;
    }
  }
View Full Code Here

  }
 
  @Override
  protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
   
    Instance instance = converter.convert(instanceId, value.toString());
   
    for (int index = 0; index < keys.length; index++) {
      int prediction = trees[index].classify(instance);
      callbacks[index].prediction(index, instanceId, prediction);
    }
View Full Code Here

TOP

Related Classes of org.apache.mahout.df.data.Instance

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.