* Add data to each split data set based on the desired cross data values. Maintain the same ratio of classifications in the split set by
* selecting that ratio from outside sets. Only keep the attributes in the supporting instances that in in the white list
* */
private void crossPollinateData(Map<Serializable, ArrayList<Instance<AttributesMap>>> splitTrainingData, ArrayList<Instance<AttributesMap>> allData) {
for(Map.Entry<Serializable, ArrayList<Instance<AttributesMap>>> entry : splitTrainingData.entrySet()) {
ClassificationCounter splitClassificationCounter = ClassificationCounter.countAll(entry.getValue());
long amountCrossData = (long) Math.max(splitClassificationCounter.getTotal() * percentCrossData, minimumAmountTotalCrossData);
Set<Instance<AttributesMap>> crossData = new HashSet<>();
ClassificationCounter crossDataCount = new ClassificationCounter();
for(int i = allData.size()-1; i >= 0; i--) {
Instance<AttributesMap>instance = allData.get(i);
double classificationRatio = splitClassificationCounter.getCount(instance.getLabel()) / splitClassificationCounter.getTotal();
double targetCount = Math.max(classificationRatio * amountCrossData, minimumAmountCrossDataPerClassification);
if(shouldAddInstance(entry.getKey(), instance, crossDataCount, targetCount)) {
crossData.add(cleanSupportingData(instance));
crossDataCount.addClassification(instance.getLabel(), instance.getWeight());
}
if(crossDataCount.getTotal() >= amountCrossData) {
break;
}
}
//cross pollinate data
entry.getValue().addAll(crossData);