public static void main(String[] args) throws FileNotFoundException {

		String[] manditory_args = {};
		createCommandLineOptions();
		CommandLineUtilities.initCommandLineParameters(args, Classify.options,
				manditory_args);

		String data_file = CommandLineUtilities.getOptionValue("data");
		int size;
		ReadImageToFeatureFile fileReader;
		String prediction = CommandLineUtilities.getOptionValue("prediction");
		String model = CommandLineUtilities.getOptionValue("model");

		String mode = CommandLineUtilities.getOptionValue("mode");

		if (mode.equalsIgnoreCase("train")) {
			
			if (CommandLineUtilities.hasArg("size")) {

				size = CommandLineUtilities.getOptionValueAsInt("size");
				fileReader = new ReadImageToFeatureFile("featuredata.txt",
						data_file, size);
			} else {
				fileReader = new ReadImageToFeatureFile("featuredata.txt",
						data_file);
			}
			
			try {
				fileReader.writeDataFile();
			} catch (IOException e) {
				throw new RuntimeException("Write to data file failed!");
			}
			
			// Load the training data.
			DataReader data_reader = new DataReader("featuredata.txt", true);
			List<Instance> instances = data_reader.readData();
			data_reader.close();

			// Train the model.
			RandomFerns predictor = new RandomFerns();
			predictor.train(instances);
			saveObject(predictor, model);

		} else if (mode.equalsIgnoreCase("test")) {
			// Load the test data.
			DataReader data_reader = new DataReader("testdata.txt", true);
			List<Instance> instances = data_reader.readData();
			data_reader.close();

			// Load the model.
			Predictor predictor = (Predictor) loadObject(model);

			try {
				evaluateAndSavePredictions(predictor, instances, prediction);
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		} else {
			System.out.println("Requires mode argument.");
		}

	}