Beispiel #1
0
        public void testDLTestMatchSucceedsWithMatchedExample()
        {
            DataSet ds = DataSetFactory.getRestaurantDataSet();
            Example e  = ds.getExample(0);

            tvn.cosine.ai.learning.inductive.DecisionListTest test = new tvn.cosine.ai.learning.inductive.DecisionListTest();
            test.add("type", "French");
            Assert.IsTrue(test.matches(e));
        }
Beispiel #2
0
        public void testDLTestMatchFailsOnMismatchedExample()
        {
            DataSet ds = DataSetFactory.getRestaurantDataSet();
            Example e  = ds.getExample(0);

            tvn.cosine.ai.learning.inductive.DecisionListTest test = new tvn.cosine.ai.learning.inductive.DecisionListTest();
            test.add("type", "Thai");
            Assert.IsFalse(test.matches(e));
        }
        public void testDecisionListHandlesEmptyDataSet()
        {
            // tests first base case of recursion
            DecisionList dlist = new DecisionList("Yes", "No");

            tvn.cosine.ai.learning.inductive.DecisionListTest test1 = new tvn.cosine.ai.learning.inductive.DecisionListTest();
            test1.add("type", "Thai"); // doesn't match first example
            dlist.add(test1, "test1success");
        }
        public void testDecisionListWithSingleTestReturnsTestValueIfTestSuccessful()


        {
            DecisionList dlist = new DecisionList("Yes", "No");
            DataSet      ds    = DataSetFactory.getRestaurantDataSet();

            tvn.cosine.ai.learning.inductive.DecisionListTest test = new tvn.cosine.ai.learning.inductive.DecisionListTest();
            test.add("type", "French");

            dlist.add(test, "test1success");

            Assert.AreEqual("test1success", dlist.predict(ds.getExample(0)));
        }
Beispiel #5
0
        public void testDLTestReturnsMatchedAndUnmatchedExamplesCorrectly()


        {
            DataSet ds = DataSetFactory.getRestaurantDataSet();

            tvn.cosine.ai.learning.inductive.DecisionListTest test = new tvn.cosine.ai.learning.inductive.DecisionListTest();
            test.add("type", "Burger");

            DataSet matched = test.matchedExamples(ds);

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

            DataSet unmatched = test.unmatchedExamples(ds);

            Assert.AreEqual(8, unmatched.size());
        }
        public void testDecisionListFallsThruToDefaultIfNoTestMatches()


        {
            DecisionList dlist = new DecisionList("Yes", "No");
            DataSet      ds    = DataSetFactory.getRestaurantDataSet();

            tvn.cosine.ai.learning.inductive.DecisionListTest test1 = new tvn.cosine.ai.learning.inductive.DecisionListTest();
            test1.add("type", "Thai"); // doesn't match first example
            dlist.add(test1, "test1success");

            tvn.cosine.ai.learning.inductive.DecisionListTest test2 = new tvn.cosine.ai.learning.inductive.DecisionListTest();
            test2.add("type", "Burger");
            dlist.add(test2, "test2success");// doesn't match first example

            Assert.AreEqual("No", dlist.predict(ds.getExample(0)));
        }
        public void testDecisionListMerge()
        {
            DecisionList dlist1 = new DecisionList("Yes", "No");
            DecisionList dlist2 = new DecisionList("Yes", "No");
            DataSet      ds     = DataSetFactory.getRestaurantDataSet();

            tvn.cosine.ai.learning.inductive.DecisionListTest test1 = new tvn.cosine.ai.learning.inductive.DecisionListTest();
            test1.add("type", "Thai"); // doesn't match first example
            dlist1.add(test1, "test1success");

            tvn.cosine.ai.learning.inductive.DecisionListTest test2 = new tvn.cosine.ai.learning.inductive.DecisionListTest();
            test2.add("type", "French");
            dlist2.add(test2, "test2success");// matches first example

            DecisionList dlist3 = dlist1.mergeWith(dlist2);

            Assert.AreEqual("test2success", dlist3.predict(ds.getExample(0)));
        }
Beispiel #8
0
        public virtual ICollection <DecisionListTest> createDLTestsWithAttributeCount(DataSet ds, int i)
        {
            if (i != 1)
            {
                throw new RuntimeException("For now DLTests with only 1 attribute can be craeted , not" + i);
            }
            ICollection <string>           nonTargetAttributes = ds.getNonTargetAttributes();
            ICollection <DecisionListTest> tests = CollectionFactory.CreateQueue <DecisionListTest>();

            foreach (string ntAttribute in nonTargetAttributes)
            {
                ICollection <string> ntaValues = ds.getPossibleAttributeValues(ntAttribute);
                foreach (string ntaValue in ntaValues)
                {
                    DecisionListTest test = new DecisionListTest();
                    test.add(ntAttribute, ntaValue);
                    tests.Add(test);
                }
            }
            return(tests);
        }