예제 #1
0
  @Override
  public void doTransform(FeatureVector featureVector) {
    Map<String, Map<String, Double>> floatFeatures = featureVector.getFloatFeatures();

    if (floatFeatures == null) {
      return;
    }
    Map<String, Double> feature1 = floatFeatures.get(fieldName1);
    if (feature1 == null || feature1.isEmpty()) {
      return;
    }

    Map<String, Double> output = Util.getOrCreateFloatFeature(outputName, floatFeatures);

    for (Entry<String, Double> feature : feature1.entrySet()) {
      Double dbl = LinearLogQuantizeTransform.quantize(feature.getValue(), bucket);
      Double newVal = feature.getValue() - dbl;
      String name = feature.getKey() + '[' + bucket + "]=" + dbl;
      output.put(name, newVal);
    }
  }
예제 #2
0
  @Override
  public void doTransform(FeatureVector featureVector) {
    Map<String, Map<String, Double>> floatFeatures = featureVector.getFloatFeatures();

    if (floatFeatures == null) {
      return;
    }

    Map<String, Double> feature1 = floatFeatures.get(fieldName1);
    if (feature1 == null) {
      return;
    }

    Map<String, Double> feature2 = floatFeatures.get(fieldName2);
    if (feature2 == null) {
      return;
    }
    Double div = feature2.get(key2);
    if (div == null) {
      return;
    }

    Double scale = 1.0 / (constant + div);
    Map<String, Double> output = Util.getOrCreateFloatFeature(outputName, floatFeatures);

    Set<String> allKeys = feature1.keySet();

    for (String key : allKeys) {
      if (keys == null || keys.contains(key)) {
        Double val = feature1.get(key);
        if (val != null) {
          output.put(key + "-d-" + key2, val * scale);
        }
      }
    }
  }