public void actionPerformed(final ActionEvent e) { if (e.getSource() == this.calculateButton) { try { setDirty(true); final BasicMLData input = new BasicMLData(this.inputCount); for (int i = 0; i < this.inputCount; i++) { double value = 0; final String str = (String) this.inputTable.getValueAt(i, 1); try { value = Double.parseDouble(str); } catch (final NumberFormatException e2) { EncogWorkBench.displayError("Data Error", "Please enter a valid input number."); } input.setData(i, value); } final int output = getData().classify(input); this.outputTable.setValueAt(output, 0, 1); } catch (EncogError ex) { EncogWorkBench.displayError("Query Error", ex.getMessage()); } catch (Throwable t) { ErrorDialog.handleError(t, this.getEncogObject(), null); } } }
public static void convertCSV2Binary( File csvFile, CSVFormat format, File binFile, int[] input, int[] ideal, boolean headers) { binFile.delete(); ReadCSV csv = new ReadCSV(csvFile.toString(), headers, format); BufferedMLDataSet buffer = new BufferedMLDataSet(binFile); buffer.beginLoad(input.length, ideal.length); while (csv.next()) { BasicMLData inputData = new BasicMLData(input.length); BasicMLData idealData = new BasicMLData(ideal.length); // handle input data for (int i = 0; i < input.length; i++) { inputData.setData(i, csv.getDouble(input[i])); } // handle input data for (int i = 0; i < ideal.length; i++) { idealData.setData(i, csv.getDouble(ideal[i])); } // add to dataset buffer.add(inputData, idealData); } buffer.endLoad(); }