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)); }
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)); }
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)); }
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"); }
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))); }
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()); }
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))); }
public virtual List <DLTest> createDLTestsWithAttributeCount(DataSet ds, int i) { if (i != 1) { throw new ApplicationException( "For now DLTests with only 1 attribute can be craeted , not" + i); } List <String> nonTargetAttributes = ds.getNonTargetAttributes(); List <DLTest> tests = new List <DLTest>(); foreach (String ntAttribute in nonTargetAttributes) { List <String> ntaValues = ds.getPossibleAttributeValues(ntAttribute); foreach (String ntaValue in ntaValues) { DLTest test = new DLTest(); test.add(ntAttribute, ntaValue); tests.Add(test); } } return(tests); }
public void add(DLTest test, String outcome) { tests.Add(test); testOutcomes.Add(test, outcome); }
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))); }
public void add(DLTest test, String outcome) { tests.Add(test); testOutcomes.Add(test, outcome); }