static void decisionListDemo() { try { DataSet ds = DataSetFactory.getRestaurantDataSet(); DecisionListLearner learner = new DecisionListLearner("Yes", "No", new DecisionListTestFactory()); learner.Train(ds); System.Console.WriteLine("The Induced DecisionList is"); System.Console.WriteLine(learner.getDecisionList()); int[] result = learner.Test(ds); System.Console.WriteLine("\nThis Decision List classifies the data set with " + result[0] + " successes" + " and " + result[1] + " failures"); System.Console.WriteLine("\n"); } catch (Exception e) { System.Console.WriteLine("Decision ListDemo Failed"); throw e; } }
public void testDecisionListLearnerReturnsFailureWhenTestsEmpty() { // tests second base case of DL Learner DecisionListLearner learner = new DecisionListLearner("Yes", "No", new MockDLTestFactory(CollectionFactory.CreateQueue <aima.net.learning.inductive.DecisionListTest>())); DataSet ds = DataSetFactory.getRestaurantDataSet(); learner.Train(ds); Assert.AreEqual(DecisionListLearner.FAILURE, learner.Predict(ds.getExample(0))); }
public void testDecisionListTestRunOnRestaurantDataSet() { DataSet ds = DataSetFactory.getRestaurantDataSet(); DecisionListLearner learner = new DecisionListLearner("Yes", "No", new DecisionListTestFactory()); learner.Train(ds); int[] result = learner.Test(ds); Assert.AreEqual(12, result[0]); Assert.AreEqual(0, result[1]); }
public void testDecisionListLearnerReturnsNegativeDLWhenDataSetEmpty() { // tests first base case of DL Learner DecisionListLearner learner = new DecisionListLearner("Yes", "No", new MockDLTestFactory(null)); DataSet ds = DataSetFactory.getRestaurantDataSet(); DataSet empty = ds.emptyDataSet(); learner.Train(empty); Assert.AreEqual("No", learner.Predict(ds.getExample(0))); Assert.AreEqual("No", learner.Predict(ds.getExample(1))); Assert.AreEqual("No", learner.Predict(ds.getExample(2))); }