/** * tests whether the classifier produces the same model when trained * incrementally as when batch trained. * * @see CheckClassifier#updatingEquality(boolean, boolean, boolean, boolean, * boolean, boolean, int) * @see CheckClassifier#testsPerClassType(int, boolean, boolean, boolean) */ public void testUpdatingEquality() { boolean[] result; int i; if (m_updateableClassifier) { for (i = FIRST_CLASSTYPE; i <= LAST_CLASSTYPE; i++) { // does the classifier support this type of class at all? if (!canPredict(i)) { continue; } result = m_Tester.updatingEquality(m_NominalPredictors[i], m_NumericPredictors[i], m_StringPredictors[i], m_DatePredictors[i], m_RelationalPredictors[i], m_multiInstanceHandler, i); if (!result[0]) { System.err .println("Incremental training does not produce same result as " + "batch training (" + getClassTypeString(i) + " class)!"); } } } }
/** * tests whether the classifier handles instance weights correctly * * @see CheckClassifier#instanceWeights(boolean, boolean, boolean, boolean, * boolean, boolean, int) * @see CheckClassifier#testsPerClassType(int, boolean, boolean, boolean) */ public void testInstanceWeights() { boolean[] result; int i; if (m_weightedInstancesHandler) { for (i = FIRST_CLASSTYPE; i <= LAST_CLASSTYPE; i++) { // does the classifier support this type of class at all? if (!canPredict(i)) { continue; } result = m_Tester.instanceWeights(m_NominalPredictors[i], m_NumericPredictors[i], m_StringPredictors[i], m_DatePredictors[i], m_RelationalPredictors[i], m_multiInstanceHandler, i); if (!result[0]) { System.err.println("Error handling instance weights (" + getClassTypeString(i) + " class)!"); } } } }
/** * tests whether the classifier produces the same model when trained * incrementally as when batch trained. * * @see CheckClassifier#updatingEquality(boolean, boolean, boolean, boolean, * boolean, boolean, int) * @see CheckClassifier#testsPerClassType(int, boolean, boolean, boolean) */ public void testUpdatingEquality() { boolean[] result; int i; if (m_updateableClassifier) { for (i = FIRST_CLASSTYPE; i <= LAST_CLASSTYPE; i++) { // does the classifier support this type of class at all? if (!canPredict(i)) { continue; } result = m_Tester.updatingEquality(m_NominalPredictors[i], m_NumericPredictors[i], m_StringPredictors[i], m_DatePredictors[i], m_RelationalPredictors[i], m_multiInstanceHandler, i); if (!result[0]) { System.err .println("Incremental training does not produce same result as " + "batch training (" + getClassTypeString(i) + " class)!"); } } } }
/** * tests whether the classifier can handle missing predictors (20% and 100%) * * @see CheckClassifier#canHandleMissing(boolean, boolean, boolean, boolean, * boolean, boolean, int, boolean, boolean, int) * @see CheckClassifier#testsPerClassType(int, boolean, boolean, boolean) */ public void testMissingPredictors() { int i; for (i = FIRST_CLASSTYPE; i <= LAST_CLASSTYPE; i++) { // does the classifier support this type of class at all? if (!canPredict(i)) { continue; } // 20% missing checkMissingPredictors(i, 20, true); // 100% missing if (m_handleMissingPredictors[i]) { checkMissingPredictors(i, 100, true); } } }
/** * tests whether classifier handles data containing only a class attribute * * @see CheckClassifier#canHandleOnlyClass(boolean, boolean, boolean, boolean, * boolean, int) * @see CheckClassifier#testsPerClassType(int, boolean, boolean, boolean) */ public void testOnlyClass() { boolean[] result; int i; for (i = FIRST_CLASSTYPE; i <= LAST_CLASSTYPE; i++) { // does the classifier support this type of class at all? if (!canPredict(i)) { continue; } result = m_Tester.canHandleOnlyClass(m_NominalPredictors[i], m_NumericPredictors[i], m_StringPredictors[i], m_DatePredictors[i], m_RelationalPredictors[i], i); if (!result[0] && !result[1]) { fail("Error handling data containing only the class!"); } } }
/** * tests whether the classifier can handle missing predictors (20% and 100%) * * @see CheckClassifier#canHandleMissing(boolean, boolean, boolean, boolean, * boolean, boolean, int, boolean, boolean, int) * @see CheckClassifier#testsPerClassType(int, boolean, boolean, boolean) */ public void testMissingPredictors() { int i; for (i = FIRST_CLASSTYPE; i <= LAST_CLASSTYPE; i++) { // does the classifier support this type of class at all? if (!canPredict(i)) { continue; } // 20% missing checkMissingPredictors(i, 20, true); // 100% missing if (m_handleMissingPredictors[i]) { checkMissingPredictors(i, 100, true); } } }
/** * tests whether the classifier can handle missing class values (20% and 100%) * * @see CheckClassifier#canHandleMissing(boolean, boolean, boolean, boolean, * boolean, boolean, int, boolean, boolean, int) * @see CheckClassifier#testsPerClassType(int, boolean, boolean, boolean) */ public void testMissingClass() { int i; for (i = FIRST_CLASSTYPE; i <= LAST_CLASSTYPE; i++) { // does the classifier support this type of class at all? if (!canPredict(i)) { continue; } // 20% missing checkMissingClass(i, 20, true); // 100% missing if (m_handleMissingClass[i]) { checkMissingClass(i, 100, true); } } }
/** * tests whether the classifier can handle missing class values (20% and 100%) * * @see CheckClassifier#canHandleMissing(boolean, boolean, boolean, boolean, * boolean, boolean, int, boolean, boolean, int) * @see CheckClassifier#testsPerClassType(int, boolean, boolean, boolean) */ public void testMissingClass() { int i; for (i = FIRST_CLASSTYPE; i <= LAST_CLASSTYPE; i++) { // does the classifier support this type of class at all? if (!canPredict(i)) { continue; } // 20% missing checkMissingClass(i, 20, true); // 100% missing if (m_handleMissingClass[i]) { checkMissingClass(i, 100, true); } } }
/** * tests whether classifier handles N classes * * @see CheckClassifier#canHandleNClasses(boolean, boolean, boolean, boolean, * boolean, boolean, int) * @see CheckClassifier#testsPerClassType(int, boolean, boolean, boolean) * @see #m_NClasses */ public void testNClasses() { boolean[] result; if (!canPredict(Attribute.NOMINAL)) { return; } result = m_Tester.canHandleNClasses(m_NominalPredictors[Attribute.NOMINAL], m_NumericPredictors[Attribute.NOMINAL], m_StringPredictors[Attribute.NOMINAL], m_DatePredictors[Attribute.NOMINAL], m_RelationalPredictors[Attribute.NOMINAL], m_multiInstanceHandler, m_NClasses); if (!result[0] && !result[1]) { fail("Error handling " + m_NClasses + " classes!"); } }
/** * tests whether classifier handles N classes * * @see CheckClassifier#canHandleNClasses(boolean, boolean, boolean, boolean, * boolean, boolean, int) * @see CheckClassifier#testsPerClassType(int, boolean, boolean, boolean) * @see #m_NClasses */ public void testNClasses() { boolean[] result; if (!canPredict(Attribute.NOMINAL)) { return; } result = m_Tester.canHandleNClasses(m_NominalPredictors[Attribute.NOMINAL], m_NumericPredictors[Attribute.NOMINAL], m_StringPredictors[Attribute.NOMINAL], m_DatePredictors[Attribute.NOMINAL], m_RelationalPredictors[Attribute.NOMINAL], m_multiInstanceHandler, m_NClasses); if (!result[0] && !result[1]) { fail("Error handling " + m_NClasses + " classes!"); } }
/** * tests whether classifier handles data containing only a class attribute * * @see CheckClassifier#canHandleOnlyClass(boolean, boolean, boolean, boolean, * boolean, int) * @see CheckClassifier#testsPerClassType(int, boolean, boolean, boolean) */ public void testOnlyClass() { boolean[] result; int i; for (i = FIRST_CLASSTYPE; i <= LAST_CLASSTYPE; i++) { // does the classifier support this type of class at all? if (!canPredict(i)) { continue; } result = m_Tester.canHandleOnlyClass(m_NominalPredictors[i], m_NumericPredictors[i], m_StringPredictors[i], m_DatePredictors[i], m_RelationalPredictors[i], i); if (!result[0] && !result[1]) { fail("Error handling data containing only the class!"); } } }
/** * Tests whether the classifier can handle class attributes as Nth attribute. * In case of multi-instance classifiers it performs no tests, since the * multi-instance data has a fixed format (bagID,bag,class). * * @see CheckClassifier#canHandleClassAsNthAttribute(boolean, boolean, * boolean, boolean, boolean, boolean, int, int) * @see CheckClassifier#testsPerClassType(int, boolean, boolean, boolean) */ public void testClassAsNthAttribute() { int i; // multi-Instance data has fixed format! if (m_multiInstanceHandler) { return; } for (i = FIRST_CLASSTYPE; i <= LAST_CLASSTYPE; i++) { // does the classifier support this type of class at all? if (!canPredict(i)) { continue; } // first attribute m_handleClassAsFirstAttribute[i] = checkClassAsNthAttribute(i, 0); // second attribute m_handleClassAsSecondAttribute[i] = checkClassAsNthAttribute(i, 1); } }
/** * tests whether the classifier erroneously uses the class value of test * instances (if provided) * * @see CheckClassifier#doesntUseTestClassVal(boolean, boolean, boolean, * boolean, boolean, boolean, int) * @see CheckClassifier#testsPerClassType(int, boolean, boolean, boolean) */ public void testUseOfTestClassValue() { boolean[] result; int i; for (i = FIRST_CLASSTYPE; i <= LAST_CLASSTYPE; i++) { // does the classifier support this type of class at all? if (!canPredict(i)) { continue; } result = m_Tester.doesntUseTestClassVal(m_NominalPredictors[i], m_NumericPredictors[i], m_StringPredictors[i], m_DatePredictors[i], m_RelationalPredictors[i], m_multiInstanceHandler, i); if (!result[0]) { fail("Uses test class values (" + getClassTypeString(i) + " class)!"); } } }
/** * tests whether the classifier correctly initializes in the buildClassifier * method * * @see CheckClassifier#correctBuildInitialisation(boolean, boolean, boolean, * boolean, boolean, boolean, int) * @see CheckClassifier#testsPerClassType(int, boolean, boolean, boolean) */ public void testBuildInitialization() { boolean[] result; int i; for (i = FIRST_CLASSTYPE; i <= LAST_CLASSTYPE; i++) { // does the classifier support this type of class at all? if (!canPredict(i)) { continue; } result = m_Tester.correctBuildInitialisation(m_NominalPredictors[i], m_NumericPredictors[i], m_StringPredictors[i], m_DatePredictors[i], m_RelationalPredictors[i], m_multiInstanceHandler, i); if (!result[0] && !result[1]) { fail("Incorrect build initialization (" + getClassTypeString(i) + " class)!"); } } }
/** * tests whether the classifier can handle zero training instances * * @see CheckClassifier#canHandleZeroTraining(boolean, boolean, boolean, * boolean, boolean, boolean, int) * @see CheckClassifier#testsPerClassType(int, boolean, boolean, boolean) */ public void testZeroTraining() { boolean[] result; int i; for (i = FIRST_CLASSTYPE; i <= LAST_CLASSTYPE; i++) { // does the classifier support this type of class at all? if (!canPredict(i)) { continue; } result = m_Tester.canHandleZeroTraining(m_NominalPredictors[i], m_NumericPredictors[i], m_StringPredictors[i], m_DatePredictors[i], m_RelationalPredictors[i], m_multiInstanceHandler, i); if (!result[0] && !result[1]) { fail("Error handling zero training instances (" + getClassTypeString(i) + " class)!"); } } }
/** * tests whether the classifier can handle zero training instances * * @see CheckClassifier#canHandleZeroTraining(boolean, boolean, boolean, * boolean, boolean, boolean, int) * @see CheckClassifier#testsPerClassType(int, boolean, boolean, boolean) */ public void testZeroTraining() { boolean[] result; int i; for (i = FIRST_CLASSTYPE; i <= LAST_CLASSTYPE; i++) { // does the classifier support this type of class at all? if (!canPredict(i)) { continue; } result = m_Tester.canHandleZeroTraining(m_NominalPredictors[i], m_NumericPredictors[i], m_StringPredictors[i], m_DatePredictors[i], m_RelationalPredictors[i], m_multiInstanceHandler, i); if (!result[0] && !result[1]) { fail("Error handling zero training instances (" + getClassTypeString(i) + " class)!"); } } }
/** * tests whether the classifier erroneously uses the class value of test * instances (if provided) * * @see CheckClassifier#doesntUseTestClassVal(boolean, boolean, boolean, * boolean, boolean, boolean, int) * @see CheckClassifier#testsPerClassType(int, boolean, boolean, boolean) */ public void testUseOfTestClassValue() { boolean[] result; int i; for (i = FIRST_CLASSTYPE; i <= LAST_CLASSTYPE; i++) { // does the classifier support this type of class at all? if (!canPredict(i)) { continue; } result = m_Tester.doesntUseTestClassVal(m_NominalPredictors[i], m_NumericPredictors[i], m_StringPredictors[i], m_DatePredictors[i], m_RelationalPredictors[i], m_multiInstanceHandler, i); if (!result[0]) { fail("Uses test class values (" + getClassTypeString(i) + " class)!"); } } }
/** * tests whether the classifier alters the training set during training. * * @see CheckClassifier#datasetIntegrity(boolean, boolean, boolean, boolean, * boolean, boolean, int, boolean, boolean) * @see CheckClassifier#testsPerClassType(int, boolean, boolean, boolean) */ public void testDatasetIntegrity() { boolean[] result; int i; for (i = FIRST_CLASSTYPE; i <= LAST_CLASSTYPE; i++) { // does the classifier support this type of class at all? if (!canPredict(i)) { continue; } result = m_Tester.datasetIntegrity(m_NominalPredictors[i], m_NumericPredictors[i], m_StringPredictors[i], m_DatePredictors[i], m_RelationalPredictors[i], m_multiInstanceHandler, i, m_handleMissingPredictors[i], m_handleMissingClass[i]); if (!result[0] && !result[1]) { fail("Training set is altered during training (" + getClassTypeString(i) + " class)!"); } } }
/** * tests whether the classifier correctly initializes in the buildClassifier * method * * @see CheckClassifier#correctBuildInitialisation(boolean, boolean, boolean, * boolean, boolean, boolean, int) * @see CheckClassifier#testsPerClassType(int, boolean, boolean, boolean) */ public void testBuildInitialization() { boolean[] result; int i; for (i = FIRST_CLASSTYPE; i <= LAST_CLASSTYPE; i++) { // does the classifier support this type of class at all? if (!canPredict(i)) { continue; } result = m_Tester.correctBuildInitialisation(m_NominalPredictors[i], m_NumericPredictors[i], m_StringPredictors[i], m_DatePredictors[i], m_RelationalPredictors[i], m_multiInstanceHandler, i); if (!result[0] && !result[1]) { fail("Incorrect build initialization (" + getClassTypeString(i) + " class)!"); } } }
/** * tests whether the classifier alters the training set during training. * * @see CheckClassifier#datasetIntegrity(boolean, boolean, boolean, boolean, * boolean, boolean, int, boolean, boolean) * @see CheckClassifier#testsPerClassType(int, boolean, boolean, boolean) */ public void testDatasetIntegrity() { boolean[] result; int i; for (i = FIRST_CLASSTYPE; i <= LAST_CLASSTYPE; i++) { // does the classifier support this type of class at all? if (!canPredict(i)) { continue; } result = m_Tester.datasetIntegrity(m_NominalPredictors[i], m_NumericPredictors[i], m_StringPredictors[i], m_DatePredictors[i], m_RelationalPredictors[i], m_multiInstanceHandler, i, m_handleMissingPredictors[i], m_handleMissingClass[i]); if (!result[0] && !result[1]) { fail("Training set is altered during training (" + getClassTypeString(i) + " class)!"); } } }