}
if (count < 3)
{
throw new Exception("Count must be greater than 2");
}
PipelineWorkflow workflow = new PipelineWorkflow();
SQLQuery query = new SQLQuery();
query.setResourceID(resource);
query.addExpression("SELECT outlook, windy, temperature, humidity, weather.play FROM weather JOIN measurements ON weather.id = measurements.id");
workflow.add(query);
ListRandomSplit split = new ListRandomSplit();
split.setNumberOfOutputs(count);
split.connectDataInput(query.getDataOutput());
workflow.add(split);
TupleUnionAll[] union = new TupleUnionAll[count];
BuildClassifier[] classifier = new BuildClassifier[count];
TupleToWebRowSetCharArrays[] tupleToWRS = new TupleToWebRowSetCharArrays[count];
for (int i=0; i<count; i++)
{
union[i] = new TupleUnionAll();
union[i].setNumberOfInputs(count-1);
for (int j=0; j<i; j++)
{
union[i].connectDataInput(j, split.getOutput(j));
}
for (int j=i+1; j<count; j++)
{
union[i].connectDataInput(j-1, split.getOutput(j));
}
workflow.add(union[i]);
classifier[i] = new BuildClassifier();
classifier[i].newNominalValues();
classifier[i].addNominalValues(0, "sunny", "overcast", "rain");
classifier[i].addNominalValues(1, "true", "false");
classifier[i].addNominalValues(4, "yes", "no");
classifier[i].finishNominalValues();
classifier[i].addClassIndex(4);
classifier[i].connectDataInput(union[i].getDataOutput());
DeliverToRequestStatus deliverDT = new DeliverToRequestStatus();
deliverDT.connectInput(classifier[i].getResultOutput());
TupleProjectByIDS project = new TupleProjectByIDS();
project.addColumnIDs(new int[] {4});
project.connectDataInput(union[i].getDataOutput());
Classify classify = new Classify();
classify.connectDataInput(union[i].getDataOutput());
classify.connectClassifierInput(classifier[i].getResultOutput());
Evaluate evaluate = new Evaluate();
evaluate.connectExpectedDataInput(project.getDataOutput());
evaluate.connectPredictedDataInput(classify.getResultOutput());
tupleToWRS[i] = new TupleToWebRowSetCharArrays();
tupleToWRS[i].connectDataInput(evaluate.getResultOutput());
DeliverToRequestStatus deliverEval = new DeliverToRequestStatus();
deliverEval.connectInput(tupleToWRS[i].getResultOutput());
workflow.add(classifier[i]);
workflow.add(classify);
workflow.add(project);
workflow.add(evaluate);
workflow.add(tupleToWRS[i]);
workflow.add(deliverDT);
workflow.add(deliverEval);
}
new Execute(service).execute(workflow);
for (int i=0; i<count; i++)