Package aima.core.learning.framework

Examples of aima.core.learning.framework.Example.targetValue()


  private boolean allExamplesHaveSameClassification(DataSet ds) {
    String classification = ds.getExample(0).targetValue();
    Iterator<Example> iter = ds.iterator();
    while (iter.hasNext()) {
      Example element = iter.next();
      if (!(element.targetValue().equals(classification))) {
        return false;
      }

    }
    return true;
View Full Code Here


  private double calculateError(DataSet ds, Learner l) {
    double error = 0.0;
    for (int i = 0; i < ds.examples.size(); i++) {
      Example e = ds.getExample(i);
      if (!(l.predict(e).equals(e.targetValue()))) {
        error = error + exampleWeights[i];
      }
    }
    return error;
  }
View Full Code Here

  private void adjustExampleWeights(DataSet ds, Learner l, double error) {
    double epsilon = error / (1.0 - error);
    for (int j = 0; j < ds.examples.size(); j++) {
      Example e = ds.getExample(j);
      if ((l.predict(e).equals(e.targetValue()))) {
        exampleWeights[j] = exampleWeights[j] * epsilon;
      }
    }
    exampleWeights = Util.normalize(exampleWeights);
  }
View Full Code Here

  private boolean allExamplesHaveSameClassification(DataSet ds) {
    String classification = ds.getExample(0).targetValue();
    Iterator<Example> iter = ds.iterator();
    while (iter.hasNext()) {
      Example element = iter.next();
      if (!(element.targetValue().equals(classification))) {
        return false;
      }

    }
    return true;
View Full Code Here

    Assert.assertEquals(YES, first.getAttributeValueAsString("alternate"));
    Assert.assertEquals("$$$", first.getAttributeValueAsString("price"));
    Assert.assertEquals("0-10",
        first.getAttributeValueAsString("wait_estimate"));
    Assert.assertEquals(YES, first.getAttributeValueAsString("will_wait"));
    Assert.assertEquals(YES, first.targetValue());
  }

  @Test(expected = Exception.class)
  public void testThrowsExceptionForNonExistentFile() throws Exception {
    new DataSetFactory().fromFile("nonexistent", null, null);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.