コード例 #1
0
        public void testDLTestMatchFailsOnMismatchedExample()
        {
            DataSet ds   = DataSetFactory.getRestaurantDataSet();
            Example e    = ds.getExample(0);
            DLTest  test = new DLTest();

            test.add("type", "Thai");
            Assert.IsFalse(test.matches(e));
        }
コード例 #2
0
        public void testDLTestMatchesEvenOnMismatchedTargetAttributeValue()
        {
            DataSet ds   = DataSetFactory.getRestaurantDataSet();
            Example e    = ds.getExample(0);
            DLTest  test = new DLTest();

            test.add("type", "French");
            Assert.IsTrue(test.matches(e));
        }
コード例 #3
0
        public void testDLTestMatchSucceedsWithMatchedExample()
        {
            DataSet ds   = DataSetFactory.getRestaurantDataSet();
            Example e    = ds.getExample(0);
            DLTest  test = new DLTest();

            test.add("type", "French");
            Assert.IsTrue(test.matches(e));
        }
コード例 #4
0
        public void testDecisionListHandlesEmptyDataSet()
        {
            // tests first base case of recursion
            DecisionList dlist = new DecisionList("Yes", "No");

            DLTest test1 = new DLTest();

            test1.add("type", "Thai"); // doesn't match first example
            dlist.add(test1, "test1success");
        }
コード例 #5
0
        public void testDecisionListWithSingleTestReturnsTestValueIfTestSuccessful()
        {
            DecisionList dlist = new DecisionList("Yes", "No");
            DataSet      ds    = DataSetFactory.getRestaurantDataSet();

            DLTest test = new DLTest();

            test.add("type", "French");

            dlist.add(test, "test1success");

            Assert.AreEqual("test1success", dlist.predict(ds.getExample(0)));
        }
コード例 #6
0
        public void testDLTestReturnsMatchedAndUnmatchedExamplesCorrectly()
        {
            DataSet ds   = DataSetFactory.getRestaurantDataSet();
            DLTest  test = new DLTest();

            test.add("type", "Burger");

            DataSet matched = test.matchedExamples(ds);

            Assert.AreEqual(4, matched.size());

            DataSet unmatched = test.unmatchedExamples(ds);

            Assert.AreEqual(8, unmatched.size());
        }
コード例 #7
0
        public void testDecisionListFallsThruToDefaultIfNoTestMatches()
        {
            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.AreEqual("No", dlist.predict(ds.getExample(0)));
        }
コード例 #8
0
        public void testDecisionListMerge()
        {
            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.AreEqual("test2success", dlist3.predict(ds.getExample(0)));
        }