org.encog.ml.data.buffer.codec
Class CSVDataCODEC
- java.lang.Object
-
- org.encog.ml.data.buffer.codec.CSVDataCODEC
-
- All Implemented Interfaces:
- DataSetCODEC
public class CSVDataCODEC extends java.lang.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
Constructors Constructor and Description CSVDataCODEC(java.io.File theFile, CSVFormat theFormat, boolean theExpectSignificance)Constructor to create CSV from binary..CSVDataCODEC(java.io.File theFile, CSVFormat theFormat, boolean theHeaders, int theInputCount, int theIdealCount, boolean theExpectSignificance)Create a CODEC to load data from CSV to binary.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidclose()Close any open files.intgetIdealSize()intgetInputSize()voidprepareRead()Prepare to read from the CSV file.voidprepareWrite(int recordCount, int inputSize, int idealSize)Prepare to write to a CSV file.booleanread(double[] input, double[] ideal, double[] significance)Read one record of data from a CSV file.voidwrite(double[] input, double[] ideal, double significance)Write one record of data to a CSV file.
-
-
-
Constructor Detail
-
CSVDataCODEC
public CSVDataCODEC(java.io.File theFile, CSVFormat theFormat, boolean theExpectSignificance)Constructor to create CSV from binary..- Parameters:
theFile- The CSV file to create.theFormat- The format for that CSV file.theExpectSignificance- True, if a significance column is expected.
-
CSVDataCODEC
public CSVDataCODEC(java.io.File theFile, CSVFormat theFormat, boolean theHeaders, int theInputCount, int theIdealCount, boolean theExpectSignificance)Create a CODEC to load data from CSV to binary.- Parameters:
theFile- The CSV file to load.theFormat- The format that the CSV file is in.theHeaders- True, if there are headers.theInputCount- The number of input columns.theIdealCount- The number of ideal columns.theExpectSignificance- True, if a significance column is expected.
-
-
Method Detail
-
close
public void close()
Close any open files.- Specified by:
closein interfaceDataSetCODEC
-
getIdealSize
public int getIdealSize()
- Specified by:
getIdealSizein interfaceDataSetCODEC- Returns:
- The size of the ideal data.
-
getInputSize
public int getInputSize()
- Specified by:
getInputSizein interfaceDataSetCODEC- Returns:
- The size of the input data.
-
prepareRead
public void prepareRead()
Prepare to read from the CSV file.- Specified by:
prepareReadin interfaceDataSetCODEC
-
prepareWrite
public void prepareWrite(int recordCount, int inputSize, int idealSize)Prepare to write to a CSV file.- Specified by:
prepareWritein interfaceDataSetCODEC- Parameters:
recordCount- The total record count, that will be written.inputSize- The input size.idealSize- The ideal size.
-
read
public boolean read(double[] input, double[] ideal, double[] significance)Read one record of data from a CSV file.- Specified by:
readin interfaceDataSetCODEC- Parameters:
input- The input data array.ideal- The ideal data array.significance- The significance. The first element will be modified to hold the significance.- Returns:
- True, if there is more data to be read.
-
write
public void write(double[] input, double[] ideal, double significance)Write one record of data to a CSV file.- Specified by:
writein interfaceDataSetCODEC- Parameters:
input- The input data array.ideal- The ideal data array.significance- The significance (full = 1.0)
-
-
DMelt 3.0 © DataMelt by jWork.ORG