/** * Generates output file for a clasification problem @ param Foutput Name of the output file @ * param real Vector of outputs instances @ param obtained Vector of net outputs * * @return Nothing */ public void generateResultsClasification(String Foutput, int[] real, int[] obtained) { // Output file, classification problems FileOutputStream out; PrintStream p; Attribute at = Attributes.getOutputAttribute(0); // Check whether the output value is nominal or integer boolean isNominal = (at.getType() == at.NOMINAL); try { out = new FileOutputStream(Foutput); p = new PrintStream(out); CopyHeaderTest(p); // System.out.println("Longitudes "+real.length+" "+obtained.length); for (int i = 0; i < real.length; i++) { // Write the label associated to the class number, // when the output is nominal if (isNominal) p.print(at.getNominalValue(real[i]) + " " + at.getNominalValue(obtained[i]) + "\n"); else p.print(real[i] + " " + obtained[i] + "\n"); } p.close(); } catch (Exception e) { System.err.println("Error building file for results: " + Foutput); } }
/** * Generates output file for a modelling problem @ param Foutput Name of the output file @ param * real Vector of outputs instances @ param obtained Vector of net outputs * * @return Nothing */ public void generateResultsModeling(String Foutput, double[] real, double[] obtained) { // Output file, modeling problems FileOutputStream out; PrintStream p; try { out = new FileOutputStream(Foutput); p = new PrintStream(out); CopyHeaderTest(p); for (int i = 0; i < real.length; i++) { p.print(real[i] + " " + obtained[i] + "\n"); } p.close(); } catch (Exception e) { System.err.println("Error building file for results: " + Foutput); } }
/** * Generating the header of the output file @ param p PrintStream * * @return Nothing */ private void CopyHeaderTest(PrintStream p) { // Header of the output file p.println("@relation " + Attributes.getRelationName()); p.print(Attributes.getInputAttributesHeader()); p.print(Attributes.getOutputAttributesHeader()); p.println(Attributes.getInputHeader()); p.println(Attributes.getOutputHeader()); p.println("@data"); }