use of com.airbnb.aerosolve.core.FeatureVector in project aerosolve by airbnb.
the class FloatToDenseTransformTest method testFull.
@Test
public void testFull() {
FeatureVector featureVector = testTransform(makeFeatureVectorFull());
Map<String, List<Double>> denseFeatures = featureVector.getDenseFeatures();
assertNotNull(denseFeatures);
assertEquals(1, denseFeatures.size());
List<Double> out = denseFeatures.get("x^y^z");
assertEquals(3, out.size());
assertEquals(50.0, out.get(0), 0.01);
assertEquals(1.3, out.get(1), 0.01);
assertEquals(2000, out.get(2), 0.01);
}
use of com.airbnb.aerosolve.core.FeatureVector in project aerosolve by airbnb.
the class FloatToStringTransformTest method testEmptyFeatureVector.
@Test
public void testEmptyFeatureVector() {
Config config = ConfigFactory.parseString(makeConfig());
Transform transform = TransformFactory.createTransform(config, "test_float_to_string_and_float");
FeatureVector featureVector = new FeatureVector();
transform.doTransform(featureVector);
assertTrue(featureVector.getStringFeatures() == null);
assertTrue(featureVector.getFloatFeatures() == null);
}
use of com.airbnb.aerosolve.core.FeatureVector in project aerosolve by airbnb.
the class KdtreeContinuousTransformTest method makeFeatureVector.
public FeatureVector makeFeatureVector() {
Map<String, Set<String>> stringFeatures = new HashMap<>();
Map<String, Map<String, Double>> floatFeatures = new HashMap<>();
Set list = new HashSet<String>();
list.add("aaa");
list.add("bbb");
stringFeatures.put("strFeature1", list);
Map<String, Double> map = new HashMap<>();
map.put("lat", 37.7);
map.put("long", 40.0);
floatFeatures.put("loc", map);
FeatureVector featureVector = new FeatureVector();
featureVector.setStringFeatures(stringFeatures);
featureVector.setFloatFeatures(floatFeatures);
return featureVector;
}
use of com.airbnb.aerosolve.core.FeatureVector in project aerosolve by airbnb.
the class KdtreeContinuousTransformTest method testTransform.
@Test
public void testTransform() {
Config config = ConfigFactory.parseString(makeConfig());
log.info("Model encoded is " + config.getString("test_kdtree.model_base64"));
Transform transform = TransformFactory.createTransform(config, "test_kdtree");
FeatureVector featureVector = makeFeatureVector();
transform.doTransform(featureVector);
Map<String, Set<String>> stringFeatures = featureVector.getStringFeatures();
assertTrue(stringFeatures.size() == 1);
Map<String, Map<String, Double>> floatFeatures = featureVector.getFloatFeatures();
Map<String, Double> out = floatFeatures.get("loc_kdt");
log.info("loc_kdt");
for (Map.Entry<String, Double> entry : out.entrySet()) {
log.info(entry.getKey() + " = " + entry.getValue());
}
assertTrue(out.size() == 2);
// 4
// |--------------- y = 2
// 1 | 2 3
// x = 1
assertEquals(out.get("0"), 37.7 - 1.0, 0.1);
assertEquals(out.get("2"), 40.0 - 2.0, 0.1);
}
use of com.airbnb.aerosolve.core.FeatureVector in project aerosolve by airbnb.
the class MoveFloatToStringTransformTest method testTransformMoveAllKeys.
@Test
public void testTransformMoveAllKeys() {
Config config = ConfigFactory.parseString(makeConfig(true));
Transform transform = TransformFactory.createTransform(config, "test_move_float_to_string");
FeatureVector featureVector = TransformTestingHelper.makeFeatureVector();
transform.doTransform(featureVector);
Map<String, Set<String>> stringFeatures = featureVector.getStringFeatures();
assertTrue(stringFeatures.size() == 2);
Set<String> out = stringFeatures.get("loc_quantized");
assertTrue(out.size() == 3);
log.info("quantize output");
for (String string : out) {
log.info(string);
}
assertTrue(out.contains("lat=37.0"));
assertTrue(out.contains("long=40.0"));
assertTrue(out.contains("z=-20.0"));
}
Aggregations