if (this.analyst == null) {
throw new EncogError(
"Can't normalize yet, file has not been analyzed.");
}
MLDataSet result = new BasicMLDataSet();
int inputCount = this.analyst.determineInputCount();
int outputCount = this.analyst.determineOutputCount();
int totalCount = inputCount+outputCount;
boolean headers = this.analyst.getScript().getProperties()
.getPropertyBoolean(ScriptProperties.SETUP_CONFIG_INPUT_HEADERS);
final CSVFormat format = this.analyst.getScript().determineFormat();
CSVHeaders analystHeaders = new CSVHeaders(file, headers,
format);
ReadCSV csv = new ReadCSV(file.toString(), headers, format);
for (final AnalystField field : analyst.getScript().getNormalize()
.getNormalizedFields()) {
field.init();
}
TimeSeriesUtil series = new TimeSeriesUtil(analyst,true,
analystHeaders.getHeaders());
try {
// write file contents
while (csv.next()) {
double[] output = AnalystNormalizeCSV.extractFields(
this.analyst, analystHeaders, csv, totalCount,
false);
if (series.getTotalDepth() > 1) {
output = series.process(output);
}
MLDataPair pair = BasicMLDataPair.createPair(inputCount,outputCount);
for(int i=0;i<inputCount;i++) {
pair.getInput().setData(i, output[i]);
}
for(int i=0;i<outputCount;i++) {
pair.getIdeal().setData(i, output[i+inputCount]);
}
result.add(pair);
}
return result;
} finally {
if (csv != null) {
try {