Package org.apache.mahout.df.data

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


      if (line.isEmpty()) {
        continue; // skip empty lines
      }
     
      // write the tuple in files[tuple.label]
      Instance instance = converter.convert(id++, line);
      int label = instance.label;
      files[currents[label]].writeBytes(line);
      files[currents[label]].writeChar('\n');
     
      // update currents
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

                                                                     InterruptedException {
      if (firstId == null) {
        firstId = new LongWritable(key.get());
      }
     
      Instance instance = converter.convert((int) key.get(), value.toString());
     
      context.write(firstId, new IntWritable(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

    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

  public void map(LongWritable key, Text value, OutputCollector<TreeID,MapredOutput> output, Reporter reporter) 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

      String line = scanner.nextLine();
      if (line.isEmpty()) {
        continue; // skip empty lines
      }

      Instance instance = converter.convert(0, line);
      int prediction = forest.classify(rng, instance);

      if (outputPath != null) {
        ofile.writeChars(Integer.toString(prediction)); // write the prediction
        ofile.writeChar('\n');
      }

      if (analyzer != null) {
        analyzer.addInstance(dataset.getLabel(instance.getLabel()),
                             new ClassifierResult(dataset.getLabel(prediction), 1.0));
      }
    }

    scanner.close();
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

                                                                     InterruptedException {
      if (firstId == null) {
        firstId = new LongWritable(key.get());
      }
     
      Instance instance = converter.convert((int) key.get(), value.toString());
     
      context.write(firstId, new IntWritable(instance.getLabel()));
    }
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.