コード例 #1
0
 @Override
 protected ExampleSetMetaData modifyMetaData(ExampleSetMetaData exampleSetMetaData)
     throws UndefinedParameterError {
   AttributeMetaData label = exampleSetMetaData.getLabelMetaData();
   if (label != null) {
     if (label.isNumerical() && getParameterAsDouble(PARAMETER_LABEL_NOISE) > 0) {
       label.setValueSetRelation(SetRelation.SUPERSET);
     }
   }
   double defaultNoise = getParameterAsDouble(PARAMETER_DEFAULT_ATTRIBUTE_NOISE);
   if (defaultNoise > 0) {
     for (AttributeMetaData amd : exampleSetMetaData.getAllAttributes()) {
       if (!amd.isSpecial()) {
         if (amd.isNumerical()) {
           amd.setValueSetRelation(SetRelation.SUPERSET);
         }
       }
     }
   }
   int numberOfRandomAttributes = getParameterAsInt(PARAMETER_RANDOM_ATTRIBUTES);
   for (int i = 0; i < numberOfRandomAttributes; i++) {
     AttributeMetaData amd =
         new AttributeMetaData("random" + ((i == 0) ? "" : i + ""), Ontology.REAL);
     amd.setValueRange(
         new Range(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY), SetRelation.SUBSET);
     exampleSetMetaData.addAttribute(amd);
   }
   return exampleSetMetaData;
 }
コード例 #2
0
  public Vector<String> getAttributeNames() {
    Vector<String> names = new Vector<>();
    Vector<String> regularNames = new Vector<>();

    MetaData metaData = getMetaData();
    if (metaData != null) {
      if (metaData instanceof ExampleSetMetaData) {
        ExampleSetMetaData emd = (ExampleSetMetaData) metaData;
        for (AttributeMetaData amd : emd.getAllAttributes()) {
          if (!isFilteredOut(amd) && isOfAllowedType(amd.getValueType())) {
            if (amd.isSpecial()) {
              names.add(amd.getName());
            } else {
              regularNames.add(amd.getName());
            }
          }
        }
      } else if (metaData instanceof ModelMetaData) {
        ModelMetaData mmd = (ModelMetaData) metaData;
        ExampleSetMetaData emd = mmd.getTrainingSetMetaData();
        if (emd != null) {
          for (AttributeMetaData amd : emd.getAllAttributes()) {
            if (!isFilteredOut(amd) && isOfAllowedType(amd.getValueType())) {
              if (amd.isSpecial()) {
                names.add(amd.getName());
              } else {
                regularNames.add(amd.getName());
              }
            }
          }
        }
      }
    }
    Collections.sort(names);
    Collections.sort(regularNames);
    names.addAll(regularNames);

    return names;
  }
コード例 #3
0
  @Override
  public ExampleSetMetaData applyOnFilteredMetaData(ExampleSetMetaData metaData) {
    for (AttributeMetaData amd : metaData.getAllAttributes()) {
      if (amd.isNumerical() && !amd.isSpecial()) {
        Range range = amd.getValueRange();
        amd.setValueRange(
            new Range(0, Math.max(Math.abs(range.getLower()), Math.abs(range.getUpper()))),
            amd.getValueSetRelation());
        amd.getMean().setUnkown();
      }
    }

    return metaData;
  }
コード例 #4
0
  private ExampleSetMetaData applyRulesOnMetaData(
      List<String> rules, MetaData metaData, FilterConditon condition)
      throws UndefinedParameterError {
    if (metaData == null || !(metaData instanceof ExampleSetMetaData) || condition == null) {
      return new ExampleSetMetaData();
    }
    ExampleSetMetaData sortedMetaData = new ExampleSetMetaData();
    ExampleSetMetaData originalMetaData = (ExampleSetMetaData) metaData;
    Collection<AttributeMetaData> allAttributes = originalMetaData.getAllAttributes();

    // iterate over all rules
    for (String currentRule : rules) {

      // iterate over all original attributes and check if rule applies
      Iterator<AttributeMetaData> iterator = allAttributes.iterator();
      while (iterator.hasNext()) {
        AttributeMetaData attrMD = iterator.next();

        // skip special attributes
        if (attrMD.isSpecial()) {
          continue;
        }

        // if rule applies, remove attribute from unmachted list and add it to rules matched
        // list
        if (condition.match(currentRule, attrMD.getName())) {
          iterator.remove();
          sortedMetaData.addAttribute(attrMD);
        }
      }
    }

    if (!getParameterAsString(PARAMETER_HANDLE_UNMATCHED_ATTRIBUTES)
        .equals(REMOVE_UNMATCHED_MODE)) {
      sortedMetaData.addAllAttributes(allAttributes);
    }

    return sortedMetaData;
  }