예제 #1
0
        public void testDecisionListLearnerReturnsFailureWhenTestsEmpty()
        {
            // tests second base case of DL Learner
            DecisionListLearner learner = new DecisionListLearner("Yes", "No",
                                                                  new MockDLTestFactory(new List <DLTest>()));
            DataSet ds = DataSetFactory.getRestaurantDataSet();

            learner.train(ds);
            Assert.AreEqual(DecisionListLearner.FAILURE, learner.predict(ds
                                                                         .getExample(0)));
        }
예제 #2
0
        public void testDecisionListTestRunOnRestaurantDataSet()
        {
            DataSet             ds      = DataSetFactory.getRestaurantDataSet();
            DecisionListLearner learner = new DecisionListLearner("Yes", "No",
                                                                  new DLTestFactory());

            learner.train(ds);

            int[] result = learner.test(ds);
            Assert.AreEqual(12, result[0]);
            Assert.AreEqual(0, result[1]);
        }
예제 #3
0
        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)));
        }