Instances test;
Instances data;
TestInstances testInst;
int tot;
int mid;
EvaluationUtils evaluation;
FastVector regressionResults;
reg = new Regression(this.getClass());
// generate test data
try {
testInst = new TestInstances();
testInst.setClassType(Attribute.NOMINAL);
testInst.setNumNominal(5);
testInst.setNumNominalValues(4);
testInst.setNumNumeric(0);
testInst.setNumDate(0);
testInst.setNumString(0);
testInst.setNumRelational(0);
testInst.setNumInstances(100);
data = testInst.generate();
}
catch (Exception e) {
fail("Failed generating data: " + e);
return;
}
// split data into train/test
tot = data.numInstances();
mid = tot / 2;
train = null;
test = null;
try {
train = new Instances(data, 0, mid);
test = new Instances(data, mid, tot - mid);
m_Classifier = new SerializedClassifier();
m_Classifier.setModelFile(new File(MODEL_FILENAME));
}
catch (Exception e) {
e.printStackTrace();
fail("Problem setting up to use classifier: " + e);
}
evaluation = new EvaluationUtils();
try {
trainAndSerializeClassifier(train);
regressionResults = evaluation.getTrainTestPredictions(m_Classifier, train, test);
reg.println(predictionsToString(regressionResults));
}
catch (Exception e) {
fail("Failed obtaining classifier predictions: " + e);
}