return instances;
}
private Instance<AttributesMap> instanceConverter(String[] instanceArray) {
AttributesMap attributesMap = AttributesMap.newHashMap();
Serializable label = null;
double weight = 1.0;
for (int i = 0; i < header.size(); i++) {
if (i >= instanceArray.length) {
throw new IndexOutOfBoundsException();
}
if (instanceArray[i].isEmpty()) {
continue;
}
boolean haveLabelInFirstCollumn = i == 0 && columnNameForLabel == null;
boolean matchedCollumnToLabel = columnNameForLabel != null && columnNameForLabel.equals(header.get(i));
if (haveLabelInFirstCollumn || matchedCollumnToLabel) {
label = convertToNumberOrCleanedString(header.get(i), instanceArray[i]);
continue;
}
boolean matchedCollumnToWeight = columnNameForWeight != null && columnNameForWeight.equals(header.get(i));
if (matchedCollumnToWeight) {
weight = (Double) convertToNumberOrCleanedString(header.get(i), instanceArray[i]);
continue;
}
attributesMap.put(header.get(i), convertToNumberOrCleanedString(header.get(i), instanceArray[i]));
}
if (label == null) {
label = "missing label";
containsUnLabeledInstances = true;
}