/** * Begin the tests, reporting results to System.out */ public void doTests() { if (getEstimator() == null) { println("\n=== No estimator set ==="); return; } println("\n=== Check on Estimator: " + getEstimator().getClass().getName() + " ===\n"); m_ClasspathProblems = false; // Start tests with test for options canTakeOptions(); // test what type of estimator it is EstTypes estTypes = new EstTypes(); estTypes.incremental = incrementalEstimator()[0]; estTypes.weighted = weightedInstancesHandler()[0]; estTypes.supervised = supervisedEstimator()[0]; // in none of the estimators yet the functionality is depending on the class // type // since this could change the basic structure taken from checkclassifiers // is kept here int classType = Attribute.NOMINAL; AttrTypes attrTypes = testsPerClassType(classType, estTypes); // only nominal class can be split up so far canSplitUpClass(attrTypes, classType); }
print("estimator doesn't alter original datasets"); printAttributeSummary(attrTypes, classType); print("..."); int numTrain = getNumInstances(); getNumInstances(); int numClasses = 2, missingLevel = 100; boolean built = false; try { train = makeTestDataset(42, numTrain, 1, attrTypes, numClasses, classType); int attrIndex = 0; addMissing(train, missingLevel, attributeMissing, classMissing, attrIndex); estimator = Estimator.makeCopies(getEstimator(), 1)[0]; } catch (Exception ex) { throw new Error("Error setting up for tests: " + ex.getMessage()); int attrIndex = 0; estimator.addValues(trainCopy, attrIndex); compareDatasets(train, trainCopy); built = true; println("yes"); result[0] = true; } catch (Exception ex) { println("no"); result[0] = false;
attrTypes.nominal = canEstimate(at, estTypes.supervised, classType)[0]; at = new AttrTypes(Attribute.NUMERIC); attrTypes.numeric = canEstimate(at, estTypes.supervised, classType)[0]; attrTypes.string = false; attrTypes.date = false; instanceWeights(workAttrTypes, classType); canHandleNClasses(workAttrTypes, numClasses); canHandleClassAsNthAttribute(workAttrTypes, numAtt, 0, classType, 1); canHandleZeroTraining(workAttrTypes, classType); boolean handleMissingAttributes = canHandleMissing(workAttrTypes, classType, true, false, 20)[0]; if (handleMissingAttributes) { canHandleMissing(workAttrTypes, classType, true, false, 100); boolean handleMissingClass = canHandleMissing(workAttrTypes, classType, false, true, 20)[0]; if (handleMissingClass) { canHandleMissing(workAttrTypes, classType, false, true, 100); correctBuildInitialisation(workAttrTypes, classType); datasetIntegrity(workAttrTypes, classType, handleMissingAttributes, handleMissingClass); incrementingEquality(workAttrTypes, classType);
train = makeTestDataset(42, numTrain, numAtts, attrTypes, numClasses, classType, classIndex); test = makeTestValueList(24, numTest, train, attrIndex, attrTypes.getSetType()); double min = -10.0; double max = 8.0; test = makeTestValueList(24, numTest, min, max, attrTypes.getSetType()); addMissing(train, missingLevel, attributeMissing, classMissing, attrIndex); estimator = Estimator.makeCopies(getEstimator(), 1)[0]; } catch (Exception ex) { ex.printStackTrace(); testWithTestValues(estimator, test); println("yes"); result[0] = true; } catch (Exception ex) { println("no" + (acceptable ? " (OK error message)" : "")); result[1] = acceptable; println("\n=== Full Report ==="); print("Problem during"); if (built) {
/** * Test method for this class * * @param args the commandline parameters */ public static void main(String[] args) { try { CheckEstimator check = new CheckEstimator(); try { check.setOptions(args); Utils.checkForRemainingOptions(args); } catch (Exception ex) { String result = ex.getMessage() + "\n\n" + check.getClass().getName().replaceAll(".*\\.", "") + " Options:\n\n"; Enumeration<Option> enu = check.listOptions(); while (enu.hasMoreElements()) { Option option = enu.nextElement(); result += option.synopsis() + "\n" + option.description() + "\n"; } throw new Exception(result); } check.doTests(); } catch (Exception ex) { System.err.println(ex.getMessage()); } } }
/** * Checks basic estimation of one attribute of the scheme, for simple * non-troublesome datasets. * * @param attrTypes the types the estimator can work with * @param classType the class type (NOMINAL, NUMERIC, etc.) */ protected void canSplitUpClass(AttrTypes attrTypes, int classType) { if (attrTypes.nominal) { canSplitUpClass(Attribute.NOMINAL, classType); } if (attrTypes.numeric) { canSplitUpClass(Attribute.NUMERIC, classType); } }
print("estimator doesn't alter original datasets"); printAttributeSummary(attrTypes, classType); print("..."); int numTrain = getNumInstances(); getNumInstances(); int numClasses = 2, missingLevel = 100; boolean built = false; try { train = makeTestDataset(42, numTrain, 1, attrTypes, numClasses, classType); int attrIndex = 0; addMissing(train, missingLevel, attributeMissing, classMissing, attrIndex); estimator = Estimator.makeCopies(getEstimator(), 1)[0]; } catch (Exception ex) { throw new Error("Error setting up for tests: " + ex.getMessage()); int attrIndex = 0; estimator.addValues(trainCopy, attrIndex); compareDatasets(train, trainCopy); built = true; println("yes"); result[0] = true; } catch (Exception ex) { println("no"); result[0] = false;
attrTypes.nominal = canEstimate(at, estTypes.supervised, classType)[0]; at = new AttrTypes(Attribute.NUMERIC); attrTypes.numeric = canEstimate(at, estTypes.supervised, classType)[0]; attrTypes.string = false; attrTypes.date = false; instanceWeights(workAttrTypes, classType); canHandleNClasses(workAttrTypes, numClasses); canHandleClassAsNthAttribute(workAttrTypes, numAtt, 0, classType, 1); canHandleZeroTraining(workAttrTypes, classType); boolean handleMissingAttributes = canHandleMissing(workAttrTypes, classType, true, false, 20)[0]; if (handleMissingAttributes) { canHandleMissing(workAttrTypes, classType, true, false, 100); boolean handleMissingClass = canHandleMissing(workAttrTypes, classType, false, true, 20)[0]; if (handleMissingClass) { canHandleMissing(workAttrTypes, classType, false, true, 100); correctBuildInitialisation(workAttrTypes, classType); datasetIntegrity(workAttrTypes, classType, handleMissingAttributes, handleMissingClass); incrementingEquality(workAttrTypes, classType);
train = makeTestDataset(42, numTrain, numAtts, attrTypes, numClasses, classType, classIndex); test = makeTestValueList(24, numTest, train, attrIndex, attrTypes.getSetType()); double min = -10.0; double max = 8.0; test = makeTestValueList(24, numTest, min, max, attrTypes.getSetType()); addMissing(train, missingLevel, attributeMissing, classMissing, attrIndex); estimator = Estimator.makeCopies(getEstimator(), 1)[0]; } catch (Exception ex) { ex.printStackTrace(); testWithTestValues(estimator, test); println("yes"); result[0] = true; } catch (Exception ex) { println("no" + (acceptable ? " (OK error message)" : "")); result[1] = acceptable; println("\n=== Full Report ==="); print("Problem during"); if (built) {
/** * Test method for this class * * @param args the commandline parameters */ public static void main(String[] args) { try { CheckEstimator check = new CheckEstimator(); try { check.setOptions(args); Utils.checkForRemainingOptions(args); } catch (Exception ex) { String result = ex.getMessage() + "\n\n" + check.getClass().getName().replaceAll(".*\\.", "") + " Options:\n\n"; Enumeration<Option> enu = check.listOptions(); while (enu.hasMoreElements()) { Option option = enu.nextElement(); result += option.synopsis() + "\n" + option.description() + "\n"; } throw new Exception(result); } check.doTests(); } catch (Exception ex) { System.err.println(ex.getMessage()); } } }
/** * Checks basic estimation of one attribute of the scheme, for simple * non-troublesome datasets. * * @param attrTypes the types the estimator can work with * @param classType the class type (NOMINAL, NUMERIC, etc.) */ protected void canSplitUpClass(AttrTypes attrTypes, int classType) { if (attrTypes.nominal) { canSplitUpClass(Attribute.NOMINAL, classType); } if (attrTypes.numeric) { canSplitUpClass(Attribute.NUMERIC, classType); } }
print("incremental training produces the same results" + " as batch training"); printAttributeSummary(attrTypes, classType); print("..."); int numTrain = getNumInstances(), numTest = getNumInstances(), numClasses = 2, missingLevel = 0; boolean attributeMissing = false, classMissing = false; Vector<Double> test; try { train = makeTestDataset(42, numTrain, 1, attrTypes, numClasses, classType); test = makeTestValueList(24, numTest, train, attrIndex, attrTypes.getSetType()); addMissing(train, missingLevel, attributeMissing, classMissing, attrIndex); estimators = Estimator.makeCopies(getEstimator(), 2); estimators[0].addValues(train, attrIndex); } catch (Exception ex) { println("no"); result[0] = false; println("\n=== Full Report ==="); println("Results differ between batch and " + "incrementally built models.\n" + "Depending on the estimator, this may be OK");
/** * Begin the tests, reporting results to System.out */ public void doTests() { if (getEstimator() == null) { println("\n=== No estimator set ==="); return; } println("\n=== Check on Estimator: " + getEstimator().getClass().getName() + " ===\n"); m_ClasspathProblems = false; // Start tests with test for options canTakeOptions(); // test what type of estimator it is EstTypes estTypes = new EstTypes(); estTypes.incremental = incrementalEstimator()[0]; estTypes.weighted = weightedInstancesHandler()[0]; estTypes.supervised = supervisedEstimator()[0]; // in none of the estimators yet the functionality is depending on the class // type // since this could change the basic structure taken from checkclassifiers // is kept here int classType = Attribute.NOMINAL; AttrTypes attrTypes = testsPerClassType(classType, estTypes); // only nominal class can be split up so far canSplitUpClass(attrTypes, classType); }
print("correct initialisation during buildEstimator"); printAttributeSummary(attrTypes, classType); print("..."); int numTrain = getNumInstances(); getNumInstances(); int numClasses = 2, missingLevel = 0; boolean attributeMissing = false, classMissing = false; train1 = makeTestDataset(42, numTrain, 2, attrTypes, numClasses, classType); train2 = makeTestDataset(84, numTrain, 3, attrTypes, numClasses, classType); if (missingLevel > 0) { addMissing(train1, missingLevel, attributeMissing, classMissing, attrIndex1); addMissing(train2, missingLevel, attributeMissing, classMissing, attrIndex2); estimator = Estimator.makeCopies(getEstimator(), 1)[0]; } catch (Exception ex) { throw new Error("Error setting up for tests: " + ex.getMessage()); estimator1 = Estimator.makeCopies(getEstimator(), 1)[0]; if (!estimator.equals(estimator1)) { if (m_Debug) { println("\n=== Full report ===\n" + "\nFirst build estimator\n" + estimator.toString() + "\n\n");
print("correct initialisation during buildEstimator"); printAttributeSummary(attrTypes, classType); print("..."); int numTrain = getNumInstances(); getNumInstances(); int numClasses = 2, missingLevel = 0; boolean attributeMissing = false, classMissing = false; train1 = makeTestDataset(42, numTrain, 2, attrTypes, numClasses, classType); train2 = makeTestDataset(84, numTrain, 3, attrTypes, numClasses, classType); if (missingLevel > 0) { addMissing(train1, missingLevel, attributeMissing, classMissing, attrIndex1); addMissing(train2, missingLevel, attributeMissing, classMissing, attrIndex2); estimator = Estimator.makeCopies(getEstimator(), 1)[0]; } catch (Exception ex) { throw new Error("Error setting up for tests: " + ex.getMessage()); estimator1 = Estimator.makeCopies(getEstimator(), 1)[0]; if (!estimator.equals(estimator1)) { if (m_Debug) { println("\n=== Full report ===\n" + "\nFirst build estimator\n" + estimator.toString() + "\n\n");
print("incremental training produces the same results" + " as batch training"); printAttributeSummary(attrTypes, classType); print("..."); int numTrain = getNumInstances(), numTest = getNumInstances(), numClasses = 2, missingLevel = 0; boolean attributeMissing = false, classMissing = false; Vector<Double> test; try { train = makeTestDataset(42, numTrain, 1, attrTypes, numClasses, classType); test = makeTestValueList(24, numTest, train, attrIndex, attrTypes.getSetType()); addMissing(train, missingLevel, attributeMissing, classMissing, attrIndex); estimators = Estimator.makeCopies(getEstimator(), 2); estimators[0].addValues(train, attrIndex); } catch (Exception ex) { println("no"); result[0] = false; println("\n=== Full Report ==="); println("Results differ between batch and " + "incrementally built models.\n" + "Depending on the estimator, this may be OK");
print("estimator uses instance weights"); printAttributeSummary(attrTypes, classType); print("..."); int numTrain = 2 * getNumInstances(), numTest = getNumInstances(), numClasses = 2, missingLevel = 0; boolean attributeMissing = false, classMissing = false; int attrIndex = 0; try { train = makeTestDataset(42, numTrain, 1, attrTypes, numClasses, classType); test = makeTestValueList(24, numTest, train, attrIndex, attrTypes.getSetType()); addMissing(train, missingLevel, attributeMissing, classMissing, attrIndex); estimators = Estimator.makeCopies(getEstimator(), 2); resultProbsO = testWithTestValues(estimators[0], test); resultProbsW = testWithTestValues(estimators[1], test); println("yes"); result[0] = true; } catch (Exception ex) { println("no"); result[0] = false;
print("estimator uses instance weights"); printAttributeSummary(attrTypes, classType); print("..."); int numTrain = 2 * getNumInstances(), numTest = getNumInstances(), numClasses = 2, missingLevel = 0; boolean attributeMissing = false, classMissing = false; int attrIndex = 0; try { train = makeTestDataset(42, numTrain, 1, attrTypes, numClasses, classType); test = makeTestValueList(24, numTest, train, attrIndex, attrTypes.getSetType()); addMissing(train, missingLevel, attributeMissing, classMissing, attrIndex); estimators = Estimator.makeCopies(getEstimator(), 2); resultProbsO = testWithTestValues(estimators[0], test); resultProbsW = testWithTestValues(estimators[1], test); println("yes"); result[0] = true; } catch (Exception ex) { println("no"); result[0] = false;