use of com.airbnb.aerosolve.core.FeatureVector in project aerosolve by airbnb.
the class CustomMultiscaleQuantizeTransformTest method testSelectAndExcludeFeatures.
@Test
public void testSelectAndExcludeFeatures() {
Config config = ConfigFactory.parseString(makeConfig("select_features: [\"lat\", \"long\"] \n" + "exclude_features: [\"lat\"] \n"));
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() == 2);
assertTrue(out.contains("long[1.0]=40.0"));
assertTrue(out.contains("long[10.0]=40.0"));
}
use of com.airbnb.aerosolve.core.FeatureVector in project aerosolve by airbnb.
the class CustomMultiscaleQuantizeTransformTest method testExcludeFeatures.
@Test
public void testExcludeFeatures() {
Config config = ConfigFactory.parseString(makeConfig("exclude_features: [\"lat\"] \n"));
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() == 5);
assertTrue(out.contains("long[1.0]=40.0"));
assertTrue(out.contains("long[10.0]=40.0"));
assertTrue(out.contains("zero=0"));
assertTrue(out.contains("negative[1.0]=-1.0"));
assertTrue(out.contains("negative[10.0]=0.0"));
}
use of com.airbnb.aerosolve.core.FeatureVector in project aerosolve by airbnb.
the class CustomMultiscaleQuantizeTransformTest method testEmptyFeatureVector.
@Test
public void testEmptyFeatureVector() {
Config config = ConfigFactory.parseString(makeConfig(""));
Transform transform = TransformFactory.createTransform(config, "test_quantize");
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 CustomMultiscaleQuantizeTransformTest method testSelectFeatures.
@Test
public void testSelectFeatures() {
Config config = ConfigFactory.parseString(makeConfig("select_features: [\"lat\"] \n"));
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() == 2);
assertTrue(out.contains("lat[10.0]=30.0"));
assertTrue(out.contains("lat[1.0]=37.0"));
}
use of com.airbnb.aerosolve.core.FeatureVector in project aerosolve by airbnb.
the class CutFloatTransformTest method testTransform.
@Test
public void testTransform() {
Config config = ConfigFactory.parseString(makeConfig());
Transform transform = TransformFactory.createTransform(config, "test_cut");
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(2, feat1.size());
assertEquals(37.7, feat1.get("lat"), 0.1);
assertNull(feat1.get("long"));
assertEquals(-20.0, feat1.get("z"), 0.1);
}
Aggregations