* @throws Exception if something goes wrong
*/
public void testRegression() throws Exception {
int i;
boolean succeeded;
Regression reg;
Instances train;
int type;
// don't bother if not working correctly
if (m_Tester.hasClasspathProblems())
return;
reg = new Regression(this.getClass());
succeeded = false;
train = null;
for (i = FIRST_CLASSTYPE; i <= LAST_CLASSTYPE + 1; i++) {
// does the Associator support this type of class at all?
if (!canPredict(i))
continue;
if (i == LAST_CLASSTYPE + 1)
type = CheckAssociator.NO_CLASS;
else
type = i;
train = m_Tester.makeTestDataset(
42, m_Tester.getNumInstances(),
m_NominalPredictors[i] ? 2 : 0,
m_NumericPredictors[i] ? 1 : 0,
m_StringPredictors[i] ? 1 : 0,
m_DatePredictors[i] ? 1 : 0,
m_RelationalPredictors[i] ? 1 : 0,
2,
type,
m_multiInstanceHandler);
try {
m_RegressionResults[i] = useAssociator(train);
succeeded = true;
reg.println(m_RegressionResults[i]);
}
catch (Exception e) {
String msg = e.getMessage().toLowerCase();
if (msg.indexOf("not in classpath") > -1)
return;
m_RegressionResults[i] = null;
}
}
if (!succeeded) {
fail("Problem during regression testing: no successful predictions for any class type");
}
try {
String diff = reg.diff();
if (diff == null) {
System.err.println("Warning: No reference available, creating.");
} else if (!diff.equals("")) {
fail("Regression test failed. Difference:\n" + diff);
}