Package aima.test.core.unit.learning.inductive

Source Code of aima.test.core.unit.learning.inductive.DLTestTest

package aima.test.core.unit.learning.inductive;

import java.util.List;

import org.junit.Assert;
import org.junit.Test;

import aima.core.learning.framework.DataSet;
import aima.core.learning.framework.DataSetFactory;
import aima.core.learning.framework.Example;
import aima.core.learning.inductive.DLTest;
import aima.core.learning.inductive.DLTestFactory;

/**
* @author Ravi Mohan
*
*/
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());
  }

  @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));
  }

  @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));
  }

  @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));
  }

  @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());
  }
}
TOP

Related Classes of aima.test.core.unit.learning.inductive.DLTestTest

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.