static void setWekaClassAttribute(Instances instances, String class_attribute) {
    if (class_attribute != null) {
      int i = 0;
      boolean set = false;
      while (i < instances.numAttributes() && !set) {
        Attribute attr = instances.attribute(i);
        if (class_attribute.equals(attr.name())) {
          instances.setClassIndex(i);
          set = true;
        }
        ++i;
      }
      if (!set) {
        instances.setClassIndex(instances.numAttributes() - 1);
      }
    } else {
      instances.setClassIndex(instances.numAttributes() - 1);
    }
  }