Пример #1
0
  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();
  }
Пример #2
0
  /**
   * Convert a CSV file to a binary training file.
   *
   * @param csvFile The binary file.
   * @param binFile The binary file.
   * @param inputCount The number of input values.
   * @param outputCount The number of output values.
   * @param headers True, if there are headers on the CSV.
   */
  public static void convertCSV2Binary(
      String csvFile, String binFile, int inputCount, int outputCount, boolean headers) {

    (new File(binFile)).delete();
    CSVNeuralDataSet csv =
        new CSVNeuralDataSet(csvFile.toString(), inputCount, outputCount, headers);
    BufferedMLDataSet buffer = new BufferedMLDataSet(new File(binFile));
    buffer.beginLoad(inputCount, outputCount);
    for (MLDataPair pair : csv) {
      buffer.add(pair);
    }
    buffer.endLoad();
  }
Пример #3
0
 /**
  * Convert a CSV file to a binary training file.
  *
  * @param csvFile The CSV file.
  * @param binFile The binary file.
  * @param inputCount The number of input values.
  * @param outputCount The number of output values.
  * @param headers True, if there are headers on the3 CSV.
  */
 public static void convertCSV2Binary(
     final File csvFile,
     final File binFile,
     final int inputCount,
     final int outputCount,
     final boolean headers) {
   binFile.delete();
   final CSVNeuralDataSet csv =
       new CSVNeuralDataSet(csvFile.toString(), inputCount, outputCount, false);
   final BufferedMLDataSet buffer = new BufferedMLDataSet(binFile);
   buffer.beginLoad(inputCount, outputCount);
   for (final MLDataPair pair : csv) {
     buffer.add(pair);
   }
   buffer.endLoad();
 }