Examples of Example


Examples of aima.core.learning.framework.Example

  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

Examples of aima.core.learning.framework.Example

  }

  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

Examples of aima.core.learning.framework.Example

  }

  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

Examples of aima.core.learning.framework.Example

  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

Examples of aima.core.learning.framework.Example

      Numerizer numerizer) {
    // assumes all values for inout and target are doubles
    List<List<Double>> rds = new ArrayList<List<Double>>();
    for (int i = 0; i < ds.size(); i++) {
      List<Double> rexample = new ArrayList<Double>();
      Example e = ds.getExample(i);
      Pair<List<Double>, List<Double>> p = numerizer.numerize(e);
      List<Double> attributes = p.getFirst();
      for (Double d : attributes) {
        rexample.add(d);
      }
View Full Code Here

Examples of aima.core.learning.framework.Example

  }

  @Test
  public void testDLTestMatchSucceedsWithMatchedExample() throws Exception {
    DataSet ds = DataSetFactory.getRestaurantDataSet();
    Example e = ds.getExample(0);
    DLTest test = new DLTest();
    test.add("type", "French");
    Assert.assertTrue(test.matches(e));
  }
View Full Code Here

Examples of aima.core.learning.framework.Example

  }

  @Test
  public void testDLTestMatchFailsOnMismatchedExample() throws Exception {
    DataSet ds = DataSetFactory.getRestaurantDataSet();
    Example e = ds.getExample(0);
    DLTest test = new DLTest();
    test.add("type", "Thai");
    Assert.assertFalse(test.matches(e));
  }
View Full Code Here

Examples of aima.core.learning.framework.Example

  @Test
  public void testDLTestMatchesEvenOnMismatchedTargetAttributeValue()
      throws Exception {
    DataSet ds = DataSetFactory.getRestaurantDataSet();
    Example e = ds.getExample(0);
    DLTest test = new DLTest();
    test.add("type", "French");
    Assert.assertTrue(test.matches(e));
  }
View Full Code Here

Examples of aima.core.learning.framework.Example

  public void testLoadsDatasetFile() throws Exception {

    DataSet ds = DataSetFactory.getRestaurantDataSet();
    Assert.assertEquals(12, ds.size());

    Example first = ds.getExample(0);
    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());
  }
View Full Code Here

Examples of aima.core.learning.framework.Example

  @Test
  public void testLoadsIrisDataSetWithNumericAndStringAttributes()
      throws Exception {
    DataSet ds = DataSetFactory.getIrisDataSet();
    Example first = ds.getExample(0);
    Assert.assertEquals("5.1",
        first.getAttributeValueAsString("sepal_length"));
  }
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.