org.encog.neural.data.buffer.codec
Class CSVDataCODEC

java.lang.Object
  extended by org.encog.neural.data.buffer.codec.CSVDataCODEC
All Implemented Interfaces:
DataSetCODEC

public class CSVDataCODEC
extends Object
implements DataSetCODEC

A CODEC used to read/write data from/to a CSV data file. There are two constructors provided, one is for reading, the other for writing. Make sure you use the correct one for your intended purpose. This CODEC is typically used with the BinaryDataLoader, to load external data into the Encog binary training format.


Constructor Summary
CSVDataCODEC(File file, CSVFormat format)
          Constructor to create CSV from binary..
CSVDataCODEC(File file, CSVFormat format, boolean headers, int inputCount, int idealCount)
          Create a CODEC to load data from CSV to binary.
 
Method Summary
 void close()
          Close any open files.
 int getIdealSize()
          
 int getInputSize()
          
 void prepareRead()
          Prepare to read from the CSV file.
 void prepareWrite(int recordCount, int inputSize, int idealSize)
          Prepare to write to a CSV file.
 boolean read(double[] input, double[] ideal)
          Read one record of data from a CSV file.
 void write(double[] input, double[] ideal)
          Write one record of data to a CSV file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CSVDataCODEC

public CSVDataCODEC(File file,
                    CSVFormat format,
                    boolean headers,
                    int inputCount,
                    int idealCount)
Create a CODEC to load data from CSV to binary.

Parameters:
file - The CSV file to load.
format - The format that the CSV file is in.
headers - True, if there are headers.
inputCount - The number of input columns.
idealCount - The number of ideal columns.

CSVDataCODEC

public CSVDataCODEC(File file,
                    CSVFormat format)
Constructor to create CSV from binary..

Parameters:
file - The CSV file to create.
format - The format for that CSV file.
Method Detail

read

public boolean read(double[] input,
                    double[] ideal)
Read one record of data from a CSV file.

Specified by:
read in interface DataSetCODEC
Parameters:
input - The input data array.
ideal - The ideal data array.
Returns:
True, if there is more data to be read.

write

public void write(double[] input,
                  double[] ideal)
Write one record of data to a CSV file.

Specified by:
write in interface DataSetCODEC
Parameters:
input - The input data array.
ideal - The ideal data array.

prepareWrite

public void prepareWrite(int recordCount,
                         int inputSize,
                         int idealSize)
Prepare to write to a CSV file.

Specified by:
prepareWrite in interface DataSetCODEC
Parameters:
recordCount - The total record count, that will be written.
inputSize - The input size.
idealSize - The ideal size.

prepareRead

public void prepareRead()
Prepare to read from the CSV file.

Specified by:
prepareRead in interface DataSetCODEC

getInputSize

public int getInputSize()

Specified by:
getInputSize in interface DataSetCODEC
Returns:
The size of the input data.

getIdealSize

public int getIdealSize()

Specified by:
getIdealSize in interface DataSetCODEC
Returns:
The size of the ideal data.

close

public void close()
Close any open files.

Specified by:
close in interface DataSetCODEC


Copyright © 2011. All Rights Reserved.