}
// copy full model for output
SerializedObject so = new SerializedObject(clusterer);
fullClusterer = (Clusterer) so.getObject();
ClusterEvaluation eval = new ClusterEvaluation();
eval.setClusterer(clusterer);
switch (testMode) {
case 3: case 5: // Test on training
m_Log.statusMessage("Clustering training data...");
eval.evaluateClusterer(trainInst, "", false);
plotInstances.setInstances(inst);
plotInstances.setClusterEvaluation(eval);
outBuff.append("=== Model and evaluation on training set ===\n\n");
break;
case 2: // Percent split
m_Log.statusMessage("Randomizing instances...");
inst.randomize(new Random(1));
trainInst.randomize(new Random(1));
int trainSize = trainInst.numInstances() * percent / 100;
int testSize = trainInst.numInstances() - trainSize;
Instances train = new Instances(trainInst, 0, trainSize);
Instances test = new Instances(trainInst, trainSize, testSize);
Instances testVis = new Instances(inst, trainSize, testSize);
m_Log.statusMessage("Building model on training split...");
trainTimeStart = System.currentTimeMillis();
clusterer.buildClusterer(train);
trainTimeElapsed = System.currentTimeMillis() - trainTimeStart;
m_Log.statusMessage("Evaluating on test split...");
eval.evaluateClusterer(test, "", false);
plotInstances.setInstances(testVis);
plotInstances.setClusterEvaluation(eval);
outBuff.append("=== Model and evaluation on test split ===\n");
outBuff.append(clusterer.toString() + "\n");
outBuff.append("\nTime taken to build model (percentage split) : "
+ Utils.doubleToString(trainTimeElapsed / 1000.0,2)
+ " seconds\n\n");
break;
case 4: // Test on user split
m_Log.statusMessage("Evaluating on test data...");
Instances userTestT = new Instances(userTest);
if (!m_ignoreKeyList.isSelectionEmpty()) {
userTestT = removeIgnoreCols(userTestT);
}
eval.evaluateClusterer(userTestT, "", false);
plotInstances.setInstances(userTest);
plotInstances.setClusterEvaluation(eval);
outBuff.append("=== Evaluation on test set ===\n");
break;
default:
throw new Exception("Test mode not implemented");
}
outBuff.append(eval.clusterResultsToString());
outBuff.append("\n");
m_History.updateResult(name);
m_Log.logMessage("Finished " + cname);
m_Log.statusMessage("OK");
} catch (Exception ex) {