use of com.airbnb.aerosolve.core.FeatureVector in project aerosolve by airbnb.
the class NormalizeFloatTransformTest method testTransform.
@Test
public void testTransform() {
Config config = ConfigFactory.parseString(makeConfig());
Transform transform = TransformFactory.createTransform(config, "test_norm");
FeatureVector featureVector = TransformTestingHelper.makeFeatureVector();
transform.doTransform(featureVector);
Map<String, Set<String>> stringFeatures = featureVector.getStringFeatures();
assertTrue(stringFeatures.size() == 1);
Map<String, Double> feat1 = featureVector.getFloatFeatures().get("loc");
assertEquals(3, feat1.size());
double scale = 1.0 / Math.sqrt(37.7 * 37.7 + 40.0 * 40.0 + 20.0 * 20.0);
assertEquals(scale * 37.7, feat1.get("lat"), 0.1);
assertEquals(scale * 40.0, feat1.get("long"), 0.1);
assertEquals(scale * -20.0, feat1.get("z"), 0.1);
}
use of com.airbnb.aerosolve.core.FeatureVector in project aerosolve by airbnb.
the class NormalizeUtf8TransformTest method testEmptyFeatureVector.
@Test
public void testEmptyFeatureVector() {
Config config = ConfigFactory.parseString(makeConfigWithoutNormalizationFormAndOutput());
Transform transform = TransformFactory.createTransform(config, "test_normalize_utf_8");
FeatureVector featureVector = new FeatureVector();
transform.doTransform(featureVector);
assertTrue(featureVector.getStringFeatures() == null);
}
use of com.airbnb.aerosolve.core.FeatureVector in project aerosolve by airbnb.
the class NormalizeUtf8TransformTest method testTransformNfdNormalizationForm.
@Test
public void testTransformNfdNormalizationForm() {
Config config = ConfigFactory.parseString(makeConfigWithNormalizationForm("NFD"));
Transform transform = TransformFactory.createTransform(config, "test_normalize_utf_8");
FeatureVector featureVector = makeFeatureVector();
Map<String, Set<String>> stringFeatures = featureVector.getStringFeatures();
transform.doTransform(featureVector);
assertNotNull(stringFeatures);
assertEquals(2, stringFeatures.size());
Set<String> output = stringFeatures.get("bar");
assertNotNull(output);
assertEquals(1, output.size());
assertTrue(output.contains("Funky string: ϓϔẛ"));
assertTrue(Normalizer.isNormalized("Funky string: ϓϔẛ", Normalizer.Form.NFD));
}
use of com.airbnb.aerosolve.core.FeatureVector in project aerosolve by airbnb.
the class NormalizeUtf8TransformTest method testTransformNfkdNormalizationForm.
@Test
public void testTransformNfkdNormalizationForm() {
Config config = ConfigFactory.parseString(makeConfigWithNormalizationForm("NFKD"));
Transform transform = TransformFactory.createTransform(config, "test_normalize_utf_8");
FeatureVector featureVector = makeFeatureVector();
Map<String, Set<String>> stringFeatures = featureVector.getStringFeatures();
transform.doTransform(featureVector);
assertNotNull(stringFeatures);
assertEquals(2, stringFeatures.size());
Set<String> output = stringFeatures.get("bar");
assertNotNull(output);
assertEquals(1, output.size());
assertTrue(output.contains("Funky string: ΎΫṡ"));
assertTrue(Normalizer.isNormalized("Funky string: ΎΫṡ", Normalizer.Form.NFKD));
}
use of com.airbnb.aerosolve.core.FeatureVector in project aerosolve by airbnb.
the class CustomLinearLogQuantizeTransformTest method testTransform.
@Test
public void testTransform() {
Config config = ConfigFactory.parseString(makeConfig());
Transform transform = TransformFactory.createTransform(config, "test_quantize");
FeatureVector featureVector = makeFeatureVector();
transform.doTransform(featureVector);
Map<String, Set<String>> stringFeatures = featureVector.getStringFeatures();
assertTrue(stringFeatures.size() == 2);
Set<String> out = stringFeatures.get("loc_quantized");
log.info("quantize output");
for (String string : out) {
log.info(string);
}
assertTrue(out.size() == 10);
log.info("quantize output");
for (String string : out) {
log.info(string);
}
assertTrue(out.contains("a=0.0"));
assertTrue(out.contains("b=0.125"));
assertTrue(out.contains("c=1.0"));
assertTrue(out.contains("d=5.0"));
assertTrue(out.contains("e=16.0"));
assertTrue(out.contains("f=90.0"));
assertTrue(out.contains("g=350.0"));
assertTrue(out.contains("h=10000.0"));
assertTrue(out.contains("i=-1.0"));
assertTrue(out.contains("j=-22.0"));
}
Aggregations