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

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


    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


  }

  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

    int tp = (label == target && prediction == 1) ? 1 : 0;
    int fp = (label != target && prediction == 1) ? 1 : 0;
    int tn = (label != target && prediction == 0) ? 1 : 0;
    int fn = (label == target && prediction == 0) ? 1 : 0;

    return new CDFitness(tp, fp, tn, fn);
  }
View Full Code Here

    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

    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

  }

  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

    int tp = (label == target && prediction == 1) ? 1 : 0;
    int fp = (label != target && prediction == 1) ? 1 : 0;
    int tn = (label != target && prediction == 0) ? 1 : 0;
    int fn = (label == target && prediction == 0) ? 1 : 0;

    return 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.