Package aima.core.learning.framework

Examples of aima.core.learning.framework.DataSet


  @Test
  public void testDecisionListFallsThruToNextTestIfOneDoesntMatch()
      throws Exception {
    DecisionList dlist = new DecisionList("Yes", "No");
    DataSet ds = DataSetFactory.getRestaurantDataSet();

    DLTest test1 = new DLTest();
    test1.add("type", "Thai"); // doesn't match first example
    dlist.add(test1, "test1success");

    DLTest test2 = new DLTest();
    test2.add("type", "French");
    dlist.add(test2, "test2success");// matches first example

    Assert.assertEquals("test2success", dlist.predict(ds.getExample(0)));
  }
View Full Code Here


  @Test
  public void testDecisionListFallsThruToDefaultIfNoTestMatches()
      throws Exception {
    DecisionList dlist = new DecisionList("Yes", "No");
    DataSet ds = DataSetFactory.getRestaurantDataSet();

    DLTest test1 = new DLTest();
    test1.add("type", "Thai"); // doesn't match first example
    dlist.add(test1, "test1success");

    DLTest test2 = new DLTest();
    test2.add("type", "Burger");
    dlist.add(test2, "test2success");// doesn't match first example

    Assert.assertEquals("No", dlist.predict(ds.getExample(0)));
  }
View Full Code Here

  @Test
  public void testDecisionListMerge() throws Exception {
    DecisionList dlist1 = new DecisionList("Yes", "No");
    DecisionList dlist2 = new DecisionList("Yes", "No");
    DataSet ds = DataSetFactory.getRestaurantDataSet();

    DLTest test1 = new DLTest();
    test1.add("type", "Thai"); // doesn't match first example
    dlist1.add(test1, "test1success");

    DLTest test2 = new DLTest();
    test2.add("type", "French");
    dlist2.add(test2, "test2success");// matches first example

    DecisionList dlist3 = dlist1.mergeWith(dlist2);
    Assert.assertEquals("test2success", dlist3.predict(ds.getExample(0)));
  }
View Full Code Here

*/
public class DLTestTest {

  @Test
  public void testDecisionList() throws Exception {
    DataSet ds = DataSetFactory.getRestaurantDataSet();
    List<DLTest> dlTests = new DLTestFactory()
        .createDLTestsWithAttributeCount(ds, 1);
    Assert.assertEquals(26, dlTests.size());
  }
View Full Code Here

    Assert.assertEquals(26, dlTests.size());
  }

  @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

    Assert.assertTrue(test.matches(e));
  }

  @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

  }

  @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

  }

  @Test
  public void testDLTestReturnsMatchedAndUnmatchedExamplesCorrectly()
      throws Exception {
    DataSet ds = DataSetFactory.getRestaurantDataSet();
    DLTest test = new DLTest();
    test.add("type", "Burger");

    DataSet matched = test.matchedExamples(ds);
    Assert.assertEquals(4, matched.size());

    DataSet unmatched = test.unmatchedExamples(ds);
    Assert.assertEquals(8, unmatched.size());
  }
View Full Code Here

public class LearnerTests {

  @Test
  public void testMajorityLearner() throws Exception {
    MajorityLearner learner = new MajorityLearner();
    DataSet ds = DataSetFactory.getRestaurantDataSet();
    learner.train(ds);
    int[] result = learner.test(ds);
    Assert.assertEquals(6, result[0]);
    Assert.assertEquals(6, result[1]);
  }
View Full Code Here

  @Test
  public void testDefaultUsedWhenTrainingDataSetHasNoExamples()
      throws Exception {
    // tests RecursionBaseCase#1
    DataSet ds = DataSetFactory.getRestaurantDataSet();
    DecisionTreeLearner learner = new DecisionTreeLearner();

    DataSet ds2 = ds.emptyDataSet();
    Assert.assertEquals(0, ds2.size());

    learner.train(ds2);
    Assert.assertEquals("Unable To Classify",
        learner.predict(ds.getExample(0)));
  }
View Full Code Here

TOP

Related Classes of aima.core.learning.framework.DataSet

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.