Package aima.core.learning.learners

Examples of aima.core.learning.learners.DecisionTreeLearner


    System.out
        .println("\nDecisionTree Demo - Inducing a DecisionList from the Restaurant DataSet\n ");
    System.out.println(Util.ntimes("*", 100));
    try {
      DataSet ds = DataSetFactory.getRestaurantDataSet();
      DecisionTreeLearner learner = new DecisionTreeLearner();
      learner.train(ds);
      System.out.println("The Induced Decision Tree is ");
      System.out.println(learner.getDecisionTree());
      int[] result = learner.test(ds);

      System.out
          .println("\nThis Decision Tree classifies the data set with "
              + result[0]
              + " successes"
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

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

    DataSet ds2 = ds.emptyDataSet();

    // all 3 examples have the same classification (willWait = yes)
    ds2.add(ds.getExample(0));
    ds2.add(ds.getExample(2));
    ds2.add(ds.getExample(3));

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

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

    DataSet ds2 = ds.emptyDataSet();

    // 3 examples have classification = "yes" and one ,"no"
    ds2.add(ds.getExample(0));
    ds2.add(ds.getExample(1));// "no"
    ds2.add(ds.getExample(2));
    ds2.add(ds.getExample(3));
    ds2.setSpecification(new MockDataSetSpecification("will_wait"));

    learner.train(ds2);
    Assert.assertEquals("Yes", learner.predict(ds.getExample(1)));
  }
View Full Code Here

  }

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

TOP

Related Classes of aima.core.learning.learners.DecisionTreeLearner

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.