/** * Determine the ideal fields. * * @param headerList The headers. * @return The indexes of the ideal fields. */ private int[] determineIdealFields(final CSVHeaders headerList) { int[] result; final String type = getProp().getPropertyString(ScriptProperties.ML_CONFIG_TYPE); // is it non-supervised? if (type.equals(MLMethodFactory.TYPE_SOM)) { result = new int[0]; return result; } final List<Integer> fields = new ArrayList<Integer>(); for (int currentIndex = 0; currentIndex < headerList.size(); currentIndex++) { final String baseName = headerList.getBaseHeader(currentIndex); final int slice = headerList.getSlice(currentIndex); final AnalystField field = getAnalyst().getScript().findNormalizedField(baseName, slice); if (field != null && field.isOutput()) { fields.add(currentIndex); } } // allocate result array result = new int[fields.size()]; for (int i = 0; i < result.length; i++) { result[i] = fields.get(i); } return result; }
/** * Determine the input fields. * * @param headerList The headers. * @return The indexes of the input fields. */ private int[] determineInputFields(final CSVHeaders headerList) { final List<Integer> fields = new ArrayList<Integer>(); for (int currentIndex = 0; currentIndex < headerList.size(); currentIndex++) { final String baseName = headerList.getBaseHeader(currentIndex); final int slice = headerList.getSlice(currentIndex); final AnalystField field = getAnalyst().getScript().findNormalizedField(baseName, slice); if (field != null && field.isInput()) { fields.add(currentIndex); } } // allocate result array final int[] result = new int[fields.size()]; for (int i = 0; i < result.length; i++) { result[i] = fields.get(i); } return result; }