/** * 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 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)!"); } } } }
/** * checks whether the classifier can handle the given percentage of missing * predictors * * @param type the class type * @param percent the percentage of missing predictors * @param allowFail if true a fail statement may be executed * @return true if the classifier can handle it */ protected boolean checkMissingPredictors(int type, int percent, boolean allowFail) { boolean[] result; result = m_Tester.canHandleMissing(m_NominalPredictors[type], m_NumericPredictors[type], m_StringPredictors[type], m_DatePredictors[type], m_RelationalPredictors[type], m_multiInstanceHandler, type, true, false, percent); if (allowFail) { if (!result[0] && !result[1]) { fail("Error handling " + percent + "% missing predictors (" + getClassTypeString(type) + " class)!"); } } return result[0]; }
/** * checks whether the classifier can handle the given percentage of missing * class labels * * @param type the class type * @param percent the percentage of missing class labels * @param allowFail if true a fail statement may be executed * @return true if the classifier can handle it */ protected boolean checkMissingClass(int type, int percent, boolean allowFail) { boolean[] result; result = m_Tester.canHandleMissing(m_NominalPredictors[type], m_NumericPredictors[type], m_StringPredictors[type], m_DatePredictors[type], m_RelationalPredictors[type], m_multiInstanceHandler, type, false, true, percent); if (allowFail) { if (!result[0] && !result[1]) { fail("Error handling " + percent + "% missing class labels (" + getClassTypeString(type) + " class)!"); } } return result[0]; }
/** * checks whether the classifier can handle the given percentage of missing * class labels * * @param type the class type * @param percent the percentage of missing class labels * @param allowFail if true a fail statement may be executed * @return true if the classifier can handle it */ protected boolean checkMissingClass(int type, int percent, boolean allowFail) { boolean[] result; result = m_Tester.canHandleMissing(m_NominalPredictors[type], m_NumericPredictors[type], m_StringPredictors[type], m_DatePredictors[type], m_RelationalPredictors[type], m_multiInstanceHandler, type, false, true, percent); if (allowFail) { if (!result[0] && !result[1]) { fail("Error handling " + percent + "% missing class labels (" + getClassTypeString(type) + " class)!"); } } return result[0]; }
/** * checks whether the classifier can handle the given percentage of missing * predictors * * @param type the class type * @param percent the percentage of missing predictors * @param allowFail if true a fail statement may be executed * @return true if the classifier can handle it */ protected boolean checkMissingPredictors(int type, int percent, boolean allowFail) { boolean[] result; result = m_Tester.canHandleMissing(m_NominalPredictors[type], m_NumericPredictors[type], m_StringPredictors[type], m_DatePredictors[type], m_RelationalPredictors[type], m_multiInstanceHandler, type, true, false, percent); if (allowFail) { if (!result[0] && !result[1]) { fail("Error handling " + percent + "% missing predictors (" + getClassTypeString(type) + " class)!"); } } return result[0]; }
/** * checks whether the classifier can handle the class attribute at a given * position (0-based index, -1 means last). * * @param type the class type * @param position the position of the class attribute (0-based, -1 means * last) * @return true if the classifier can handle it */ protected boolean checkClassAsNthAttribute(int type, int position) { boolean[] result; String indexStr; result = m_Tester.canHandleClassAsNthAttribute(m_NominalPredictors[type], m_NumericPredictors[type], m_StringPredictors[type], m_DatePredictors[type], m_RelationalPredictors[type], m_multiInstanceHandler, type, position); if (position == -1) { indexStr = "last"; } else { indexStr = (position + 1) + "."; } if (!result[0] && !result[1]) { fail("Error handling class as " + indexStr + " attribute (" + getClassTypeString(type) + " class)!"); } return result[0]; }
/** * checks whether the classifier can handle the class attribute at a given * position (0-based index, -1 means last). * * @param type the class type * @param position the position of the class attribute (0-based, -1 means * last) * @return true if the classifier can handle it */ protected boolean checkClassAsNthAttribute(int type, int position) { boolean[] result; String indexStr; result = m_Tester.canHandleClassAsNthAttribute(m_NominalPredictors[type], m_NumericPredictors[type], m_StringPredictors[type], m_DatePredictors[type], m_RelationalPredictors[type], m_multiInstanceHandler, type, position); if (position == -1) { indexStr = "last"; } else { indexStr = (position + 1) + "."; } if (!result[0] && !result[1]) { fail("Error handling class as " + indexStr + " attribute (" + getClassTypeString(type) + " class)!"); } return result[0]; }
fail("Error handling " + att + " attributes (" + 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 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)!"); } } }
fail("Error handling " + att + " attributes (" + 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 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 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)!"); } } }