Question

currently I'm trying to scale my data file (train.nn) by using encog 3, my data file looks like this (This is a simplified example, in my real file, I have up to 249 features for each sample SP):

1,0,1,2,SP
4,5,6,1,SP

And this is my code for scaling:

File rawFile = new File(MYDIR, "train.nn");
File scaledFile = new File(MYDIR, "scaledTrain.nn");
EncogAnalyst analyst = new EncogAnalyst();

AnalystNormalizeCSV norm = new AnalystNormalizeCSV();
norm.analyze(rawFile, true, CSVFormat.ENGLISH, analyst);
norm.setProduceOutputHeaders(false);
norm.normalize(scaledFile);

But I got this error:

Exception in thread "main" org.encog.app.analyst.AnalystError: Multiple fields named: 1
    at org.encog.app.analyst.util.CSVHeaders.validateSameName(CSVHeaders.java:292)
    at org.encog.app.analyst.util.CSVHeaders.init(CSVHeaders.java:270)
    at org.encog.app.analyst.util.CSVHeaders.<init>(CSVHeaders.java:146)
    at org.encog.app.analyst.csv.normalize.AnalystNormalizeCSV.analyze(AnalystNormalizeCSV.java:147)

I really don't know why it complained about this.... Can someone show me what i did wrong here?
Thank you very much.
P/S: I already looked at this tutorial . It is not handy for me since it defined each field (feature) manually, which is bad, since in my case I have up to 249 features for each sample.

Was it helpful?

Solution

You can set up a loop like this:

int fieldCount = 249;
InputFieldCSV[] inFields = new InputFieldCSV[fieldCount];

int i = 0;
while (i < fieldCount) {

    norm.addInputField(inFields[i] = new InputFieldCSV(true, rawFile, i));
    i++;
}

Then set up further loops for the rest of the code where you see the same line repeated over. (code not tested...)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top