@Override
 protected MDInteger getSampledSize(ExampleSetMetaData emd) throws UndefinedParameterError {
   switch (getParameterAsInt(PARAMETER_SAMPLE)) {
     case SAMPLE_ABSOLUTE:
       int absoluteNumber = getParameterAsInt(PARAMETER_SAMPLE_SIZE);
       if (emd.getNumberOfExamples().isAtLeast(absoluteNumber) == MetaDataInfo.NO)
         getExampleSetInputPort()
             .addError(
                 new SimpleMetaDataError(
                     Severity.ERROR,
                     getExampleSetInputPort(),
                     Collections.singletonList(
                         new ParameterSettingQuickFix(
                             this,
                             PARAMETER_SAMPLE_SIZE,
                             emd.getNumberOfExamples().getValue().toString())),
                     "need_more_examples",
                     absoluteNumber + ""));
       return new MDInteger(absoluteNumber);
     case SAMPLE_RELATIVE:
       MDInteger number = emd.getNumberOfExamples();
       number.multiply(getParameterAsDouble(PARAMETER_SAMPLE_RATIO));
       return number;
     default:
       return new MDInteger();
   }
 }
  public ProcessLog2ExampleSet(OperatorDescription description) {
    super(description);
    ExampleSetMetaData newEMD = new ExampleSetMetaData();
    newEMD.attributesAreSuperset();
    newEMD.setNumberOfExamples(0);
    newEMD.getNumberOfExamples().increaseByUnknownAmount();
    getTransformer().addRule(new GenerateNewMDRule(exampleSetOutput, newEMD));

    dummyPorts.start();

    getTransformer().addRule(dummyPorts.makePassThroughRule());
  }
 @Override
 protected MDInteger getSampledSize(ExampleSetMetaData emd) throws UndefinedParameterError {
   switch (getParameterAsInt(PARAMETER_SAMPLE)) {
     case SAMPLE_ABSOLUTE:
       return new MDInteger(getParameterAsInt(PARAMETER_SAMPLE_SIZE));
     case SAMPLE_RELATIVE:
       MDInteger number = emd.getNumberOfExamples();
       number.multiply(getParameterAsDouble(PARAMETER_SAMPLE_RATIO));
       return number;
     default:
       return new MDInteger();
   }
 }
  @Override
  protected MetaData modifyMetaData(ExampleSetMetaData metaData) throws UndefinedParameterError {
    ExampleSetMetaData resultMD = metaData.clone();
    resultMD.clear();

    // add group by attributes
    if (isParameterSet(PARAMETER_GROUP_BY_ATTRIBUTES)
        && !getParameterAsString(PARAMETER_GROUP_BY_ATTRIBUTES).isEmpty()) {
      String attributeRegex = getParameterAsString(PARAMETER_GROUP_BY_ATTRIBUTES);
      Pattern pattern = Pattern.compile(attributeRegex);

      for (AttributeMetaData amd : metaData.getAllAttributes()) {
        if (pattern.matcher(amd.getName()).matches()) {
          if (amd.isNumerical()
              && getCompatibilityLevel().isAtMost(VERSION_5_1_6)) { // converting type to mimic
            // NumericalToPolynomial used below
            amd.setType(Ontology.NOMINAL);
            amd.setValueSet(Collections.<String>emptySet(), SetRelation.SUPERSET);
          }
          resultMD.addAttribute(amd);
        }
      }
      resultMD.getNumberOfExamples().reduceByUnknownAmount();
    }
    if (resultMD.getAllAttributes().isEmpty() && getCompatibilityLevel().isAtMost(VERSION_5_1_6)) {
      AttributeMetaData allGroup = new AttributeMetaData(GENERIC_GROUP_NAME, Ontology.NOMINAL);
      Set<String> values = new TreeSet<String>();
      values.add(GENERIC_ALL_NAME);
      allGroup.setValueSet(values, SetRelation.EQUAL);
      resultMD.addAttribute(allGroup);
      resultMD.setNumberOfExamples(new MDInteger(1));
    }

    // add aggregated attributes of default aggregation: They will apply only to those attribute not
    // mentioned explicitly
    List<String[]> parameterList = this.getParameterList(PARAMETER_AGGREGATION_ATTRIBUTES);
    HashSet<String> explicitDefinedAttributes = new HashSet<String>();
    for (String[] function : parameterList) {
      explicitDefinedAttributes.add(function[0]);
    }
    if (getParameterAsBoolean(PARAMETER_USE_DEFAULT_AGGREGATION)) {
      String defaultFunction = getParameterAsString(PARAMETER_DEFAULT_AGGREGATION_FUNCTION);
      ExampleSetMetaData metaDataSubset = attributeSelector.getMetaDataSubset(metaData, false);
      for (AttributeMetaData amd : metaDataSubset.getAllAttributes()) {
        if (!explicitDefinedAttributes.contains(amd.getName())) {
          AttributeMetaData newAMD =
              AggregationFunction.getAttributeMetaData(
                  defaultFunction, amd, getExampleSetInputPort());
          if (newAMD != null) resultMD.addAttribute(newAMD);
        }
      }
    }

    // add explicitly defined attributes of list
    for (String[] function : parameterList) {
      AttributeMetaData amd = metaData.getAttributeByName(function[0]);
      if (amd != null) {
        AttributeMetaData newMD =
            AggregationFunction.getAttributeMetaData(function[1], amd, getExampleSetInputPort());
        if (newMD != null) resultMD.addAttribute(newMD);
      } else {
        // in this case we should register a warning, but continue anyway in cases we don't have the
        // correct set available
        getExampleSetInputPort()
            .addError(
                new SimpleMetaDataError(
                    Severity.WARNING,
                    getExampleSetInputPort(),
                    "aggregation.attribute_unknown",
                    function[0]));
        AttributeMetaData newAMD =
            AggregationFunction.getAttributeMetaData(
                function[1],
                new AttributeMetaData(function[0], Ontology.ATTRIBUTE_VALUE),
                getExampleSetInputPort());
        if (newAMD != null) resultMD.addAttribute(newAMD);
      }
    }

    return resultMD;
  }
 @Override
 protected MetaData modifyMetaData(ExampleSetMetaData metaData) throws UndefinedParameterError {
   metaData.getNumberOfExamples().reduceByUnknownAmount();
   // TODO: Could instead take a look at the values of ids if nominal.
   return metaData;
 }