@Override public Dataset buildDataset() { Dataset ret = new Dataset(template, Utils.relativize(file)); int inputDim = template.inputTemplate.getDescriptionLength(); int outputDim = template.outputTemplate.getDescriptionLength(); if (file.exists()) { try { int index = 0, count = 0; BufferedReader reader = new BufferedReader(new FileReader(file)); for (String line = reader.readLine(); line != null && count < instanceNumber; line = reader.readLine(), index++) { if (index < startIndex) continue; String[] tokens = line.split(separators); Object input = getData(Arrays.copyOfRange(tokens, 0, inputDim), template.inputTemplate); Object output = getData( Arrays.copyOfRange(tokens, inputDim, inputDim + outputDim), template.outputTemplate); ret.add(template.newInstance(input, output)); count++; } reader.close(); ret.setReadyState(); } catch (IOException e) { } } return ret; }
private double[] getMetric(int row, Metrics metrics) { double[] ret = new double[metrics.data.size()]; for (int i = 0; i < ret.length; i++) { ret[i] = ((RealMatrix) metrics.data.get(i)).getEntry(row, 0); } Utils.normalize(ret, game.utils.Utils.getMax(ret)); return ret; }