Package org.apache.mahout.ga.watchmaker.cd

Examples of org.apache.mahout.ga.watchmaker.cd.CDFitness


    int tp = 0;
    int fp = 0;
    int tn = 0;
    int fn = 0;
    for (int index = 0; index < nbevals; index++) {
      CDFitness fitness = new CDFitness(rng.nextInt(100), rng.nextInt(100), rng
          .nextInt(100), rng.nextInt(100));
      tp += fitness.getTp();
      fp += fitness.getFp();
      tn += fitness.getTn();
      fn += fitness.getFn();

      evaluations.add(fitness);
    }
    expected = new CDFitness(tp, fp, tn, fn);
  }
View Full Code Here


    Set<String> keys = collector.getKeys();
    assertEquals("nb keys", 1, keys.size());
    assertTrue("bad key", keys.contains(zero.toString()));

    assertEquals("nb values", 1, collector.getValue(zero.toString()).size());
    CDFitness fitness = collector.getValue(zero.toString()).get(0);
    assertEquals(expected, fitness);

  }
View Full Code Here

    CDFitness[] expected = { TP, FP, TN, FN };
    for (String key : keys) {
      int index = Integer.parseInt(key);
      assertEquals("Values for key " + key, 1, collector.getValue(key).size());
      CDFitness eval = collector.getValue(key).get(0);

      assertEquals("Evaluation of the rule " + key, expected[index], eval);
    }

    EasyMock.verify(rule);
View Full Code Here

  private RandomRuleResults() {
  }

  public static synchronized void addResult(int ruleid, CDFitness fit) {
    CDFitness f = results.get(ruleid);
    if (f == null)
      f = new CDFitness(fit);
    else
      f.add(fit);
   
    results.put(ruleid, f);
  }
View Full Code Here

  @Override
  public int classify(DataLine dl) {
    int label = dl.getLabel();
    int prediction = rng.nextInt(2);

    CDFitness fitness = CDMapper.evaluate(target, prediction, label);
    RandomRuleResults.addResult(ruleid, fitness);

    return prediction;
  }
View Full Code Here

    Path output = new Path(outpath, "output.sorted");
    sorter.merge(outfiles, output);
   
    // import the evaluations
    LongWritable key = new LongWritable();
    CDFitness value = new CDFitness();
    Reader reader = new Reader(fs, output, conf);
   
    while (reader.next(key, value)) {
      evaluations.add(new CDFitness(value));
    }
   
    reader.close();
  }
View Full Code Here

    int fp = 0;
    int tn = 0;
    int fn = 0;
   
    while (values.hasNext()) {
      CDFitness v = values.next();
      tp += v.getTp();
      fp += v.getFp();
      tn += v.getTn();
      fn += v.getFn();
    }
   
    output.collect(key, new CDFitness(tp, fp, tn, fn));
  }
View Full Code Here

    map(key, dl, output);
  }
 
  void map(LongWritable key, DataLine dl, OutputCollector<LongWritable,CDFitness> output) throws IOException {
    for (int index = 0; index < rules.size(); index++) {
      CDFitness eval = evaluate(target, rules.get(index).classify(dl), dl.getLabel());
      output.collect(new LongWritable(index), eval);
    }
  }
View Full Code Here

    boolean labelIsTarget = label == target;
    int tp = labelIsTarget && prediction == 1 ? 1 : 0;
    int fp = !labelIsTarget && prediction == 1 ? 1 : 0;
    int tn = !labelIsTarget && prediction == 0 ? 1 : 0;
    int fn = labelIsTarget && prediction == 0 ? 1 : 0;
    return new CDFitness(tp, fp, tn, fn);
  }
View Full Code Here

      fp += v.getFp();
      tn += v.getTn();
      fn += v.getFn();
    }

    context.write(key, new CDFitness(tp, fp, tn, fn));
  }
View Full Code Here

TOP

Related Classes of org.apache.mahout.ga.watchmaker.cd.CDFitness

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.