/** Process the training and test files provided in the parameters file to the constructor. */ public void process() { try { // Load in memory a dataset that contains a classification problem IS.readSet(input_train_name, true); int in = 0; int out = 0; ndatos = IS.getNumInstances(); nvariables = Attributes.getNumAttributes(); nentradas = Attributes.getInputNumAttributes(); nsalidas = Attributes.getOutputNumAttributes(); X = new String[ndatos][nvariables]; // matrix with transformed data boolean[] isMissed = new boolean[ndatos]; // vector which points out instances with missed data try { FileWriter file_write = new FileWriter(output_train_name); file_write.write(IS.getHeader()); // now, print the normalized data file_write.write("@data\n"); // file_write.close(); PrintWriter pw = new PrintWriter(file_write); for (int i = 0; i < ndatos; i++) { Instance inst = IS.getInstance(i); if (!inst.existsAnyMissingValue()) { inst.printAsOriginal(pw); // file_write.write(inst.toString()); // DOES NOT WRITE BACK NON-DEF DIRECTION // ATTRIBUTES!!!! file_write.write("\n"); } } pw.close(); file_write.close(); } catch (IOException e) { System.out.println("IO exception = " + e); System.exit(-1); } } catch (Exception e) { System.out.println("Dataset exception = " + e); e.printStackTrace(); System.exit(-1); } // does a test file associated exist? if (input_train_name.compareTo(input_test_name) != 0) { try { // Load in memory a dataset that contains a classification problem IS.readSet(input_test_name, false); int in = 0; int out = 0; ndatos = IS.getNumInstances(); nvariables = Attributes.getNumAttributes(); nentradas = Attributes.getInputNumAttributes(); nsalidas = Attributes.getOutputNumAttributes(); X = new String[ndatos][nvariables]; // matrix with transformed data boolean[] isMissed = new boolean[ndatos]; // vector which points out instances with missed data try { FileWriter file_write = new FileWriter(output_test_name); file_write.write(IS.getHeader()); // now, print the normalized data file_write.write("@data\n"); PrintWriter pw = new PrintWriter(file_write); for (int i = 0; i < ndatos; i++) { Instance inst = IS.getInstance(i); if (!inst.existsAnyMissingValue()) { inst.printAsOriginal(pw); file_write.write("\n"); } } pw.close(); file_write.close(); } catch (IOException e) { System.out.println("IO exception = " + e); System.exit(-1); } } catch (Exception e) { System.out.println("Dataset exception = " + e); e.printStackTrace(); System.exit(-1); } } // write_results(); / since there ins't any data transformation, is not needed }