@Override
 public PredictionModelMetaData clone() {
   PredictionModelMetaData clone = (PredictionModelMetaData) super.clone();
   if (this.predictedLabelMetaData != null) {
     clone.predictedLabelMetaData = this.predictedLabelMetaData.clone();
   }
   if (this.generatedPredictionAttributes != null) {
     clone.generatedPredictionAttributes = new LinkedList<>();
     for (AttributeMetaData amd : this.generatedPredictionAttributes) {
       clone.generatedPredictionAttributes.add(amd.clone());
     }
   }
   return clone;
 }
 public SetRelation getPredictionAttributeSetRelation() {
   if (predictedLabelMetaData != null) {
     return predictedLabelMetaData.getValueSetRelation();
   } else {
     return SetRelation.UNKNOWN;
   }
 }
 public static Object convert(Object source, AttributeMetaData attr) {
   switch (attr.getDataType().getEnumType()) {
     case BOOL:
       return toBoolean(source);
     case XREF:
     case CATEGORICAL:
     case MREF:
       return source;
     case COMPOUND:
       throw new UnsupportedOperationException();
     case DATE:
       return toDate(source);
     case DATE_TIME:
       return toUtilDate(source);
     case DECIMAL:
       return toDouble(source);
     case INT:
       return toInt(source);
     case LONG:
       return toLong(source);
     default:
       return toString(source);
   }
 }
  public PredictionModelMetaData(
      Class<? extends PredictionModel> modelClass, ExampleSetMetaData trainingSetMetaData) {
    super(modelClass, trainingSetMetaData);
    if (trainingSetMetaData != null) {
      AttributeMetaData labelAttributeMetaData = trainingSetMetaData.getLabelMetaData();
      if (labelAttributeMetaData != null) {
        this.predictedLabelMetaData = labelAttributeMetaData.copy();
        this.predictedLabelMetaData.setRole(Attributes.PREDICTION_NAME);
        this.predictedLabelMetaData.setName("prediction(" + predictedLabelMetaData.getName() + ")");
        if (predictedLabelMetaData.isNumerical()) {
          this.predictedLabelMetaData.setValueSetRelation(SetRelation.SUPERSET);
        }
        this.predictedLabelMetaData.setMean(new MDReal());

        // creating confidence attributes
        generatedPredictionAttributes.add(predictedLabelMetaData);
        if (predictedLabelMetaData.isNominal()) {
          if (predictedLabelMetaData.getValueSet().isEmpty()) {
            AttributeMetaData confidence =
                new AttributeMetaData(
                    Attributes.CONFIDENCE_NAME + "(?)",
                    Ontology.REAL,
                    Attributes.CONFIDENCE_NAME + "_" + "?");
            confidence.setValueRange(new Range(0, 1), SetRelation.SUBSET);
            generatedPredictionAttributes.add(confidence);
            predictedLabelMetaData.setValueSetRelation(SetRelation.SUPERSET);
          } else {
            for (String value : predictedLabelMetaData.getValueSet()) {
              AttributeMetaData confidence =
                  new AttributeMetaData(
                      Attributes.CONFIDENCE_NAME + "(" + value + ")",
                      Ontology.REAL,
                      Attributes.CONFIDENCE_NAME + "_" + value);
              confidence.setValueRange(new Range(0, 1), SetRelation.SUBSET);
              generatedPredictionAttributes.add(confidence);
            }
          }
        }
      }
    }
  }