}
}
//Create a training controller for making the final model
TrainingController trainingController = new TrainingController();
//Configure the training controller
factory.configureTraining(trainingController);
//Run the full training
trainingController.setSegmentSet(segments);
trainingController.run();
//Get the fruits of our labors
System.out.println("== Saving Output ==");
FeatureSpecification spec = trainingController.getFeatureSpecification();
Model model = trainingController.getModel();
List<String> topFeatures = trainingController.getTopFeatures();
List<Map.Entry<String, Double>> featureWeights = trainingController.getFeatureWeights();
saveFeatureSpecification(spec, options.outputFeatureSpecFile);
saveModel(model, options.outputModelFile);
saveTopFeatures(topFeatures, options.outputTopFeaturesFile);
saveFeatureWeights(featureWeights, options.outputFeatureWeightsFile);
if (options.outputFeatureValues) {
Instances featureValues = trainingController.getFeatureValues();
saveInstances(featureValues, options.outputFeatureValuesFile);
}
} else {
throw new IllegalArgumentException("Options must be for Training");
}