Search in sources :

Example 96 with FeatureVector

use of com.airbnb.aerosolve.core.FeatureVector in project aerosolve by airbnb.

the class FloatToDenseTransformTest method makeFeatureVectorPartial.

public FeatureVector makeFeatureVectorPartial() {
    Map<String, Map<String, Double>> floatFeatures = new HashMap<>();
    Map<String, Double> floatFeature1 = new HashMap<>();
    floatFeature1.put("x", 50.0);
    floatFeature1.put("s", 2000.0);
    Map<String, Double> floatFeature2 = new HashMap<>();
    floatFeature2.put("z", 2000.0);
    floatFeature2.put("k", 2000.0);
    floatFeatures.put("floatFeature1", floatFeature1);
    floatFeatures.put("floatFeature2", floatFeature2);
    FeatureVector featureVector = new FeatureVector();
    featureVector.setFloatFeatures(floatFeatures);
    return featureVector;
}
Also used : FeatureVector(com.airbnb.aerosolve.core.FeatureVector) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map)

Example 97 with FeatureVector

use of com.airbnb.aerosolve.core.FeatureVector in project aerosolve by airbnb.

the class KdtreeTransformTest method testEmptyFeatureVector.

@Test
public void testEmptyFeatureVector() {
    Config config = ConfigFactory.parseString(makeConfig());
    Transform transform = TransformFactory.createTransform(config, "test_kdtree");
    FeatureVector featureVector = new FeatureVector();
    transform.doTransform(featureVector);
    assertTrue(featureVector.getStringFeatures() == null);
}
Also used : FeatureVector(com.airbnb.aerosolve.core.FeatureVector) Config(com.typesafe.config.Config) Test(org.junit.Test)

Example 98 with FeatureVector

use of com.airbnb.aerosolve.core.FeatureVector in project aerosolve by airbnb.

the class LinearLogQuantizeTransformTest 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);
}
Also used : FeatureVector(com.airbnb.aerosolve.core.FeatureVector) Config(com.typesafe.config.Config) Test(org.junit.Test)

Example 99 with FeatureVector

use of com.airbnb.aerosolve.core.FeatureVector in project aerosolve by airbnb.

the class ListTransformTest method testEmptyFeatureVector.

@Test
public void testEmptyFeatureVector() {
    Config config = ConfigFactory.parseString(makeConfig());
    Transform transform = TransformFactory.createTransform(config, "test_list");
    FeatureVector featureVector = new FeatureVector();
    transform.doTransform(featureVector);
    assertTrue(featureVector.getStringFeatures() == null);
}
Also used : FeatureVector(com.airbnb.aerosolve.core.FeatureVector) Config(com.typesafe.config.Config) Test(org.junit.Test)

Example 100 with FeatureVector

use of com.airbnb.aerosolve.core.FeatureVector in project aerosolve by airbnb.

the class ModelTransformsTest method testTransform.

@Test
public void testTransform() {
    Config config = ConfigFactory.parseString(makeConfig());
    Transformer transformer = new Transformer(config, "model_transforms");
    Example example = makeExample();
    transformer.combineContextAndItems(example);
    assertTrue(example.example.size() == 2);
    FeatureVector ex = example.example.get(0);
    assertTrue(ex.stringFeatures.size() == 3);
    assertTrue(ex.stringFeatures.get("guest_loc_quantized").contains("lat=10"));
    assertTrue(ex.stringFeatures.get("guest_loc_quantized").contains("long=20"));
    assertTrue(ex.stringFeatures.get("host_loc_quantized").contains("lat=31"));
    assertTrue(ex.stringFeatures.get("host_loc_quantized").contains("long=42"));
    assertTrue(ex.stringFeatures.get("gxh_loc").contains("lat=10^lat=31"));
    assertTrue(ex.stringFeatures.get("gxh_loc").contains("long=20^lat=31"));
    assertTrue(ex.stringFeatures.get("gxh_loc").contains("lat=10^long=42"));
    assertTrue(ex.stringFeatures.get("gxh_loc").contains("long=20^long=42"));
    assertTrue(ex.floatFeatures.get("guest_loc").get("lat") == 1.0);
    assertTrue(ex.floatFeatures.get("guest_loc").get("long") == 2.0);
    assertTrue(ex.floatFeatures.get("host_loc").get("lat") == 3.1);
    assertTrue(ex.floatFeatures.get("host_loc").get("long") == 4.2);
    assertTrue(ex.denseFeatures.get("guest_loc_dense").contains(1.0));
    assertTrue(ex.denseFeatures.get("guest_loc_dense").contains(2.0));
    assertTrue(ex.denseFeatures.get("host_loc_dense").contains(3.1));
    assertTrue(ex.denseFeatures.get("host_loc_dense").contains(4.2));
    log.info(example.toString());
}
Also used : FeatureVector(com.airbnb.aerosolve.core.FeatureVector) Config(com.typesafe.config.Config) Example(com.airbnb.aerosolve.core.Example) Test(org.junit.Test)

Aggregations

FeatureVector (com.airbnb.aerosolve.core.FeatureVector)225 Test (org.junit.Test)154 Config (com.typesafe.config.Config)117 Set (java.util.Set)59 HashMap (java.util.HashMap)58 HashSet (java.util.HashSet)50 Map (java.util.Map)46 ArrayList (java.util.ArrayList)11 Example (com.airbnb.aerosolve.core.Example)9 List (java.util.List)9 ModelRecord (com.airbnb.aerosolve.core.ModelRecord)5 ModelHeader (com.airbnb.aerosolve.core.ModelHeader)4 BufferedReader (java.io.BufferedReader)4 IOException (java.io.IOException)4 MulticlassScoringResult (com.airbnb.aerosolve.core.MulticlassScoringResult)3 BufferedWriter (java.io.BufferedWriter)3 CharArrayWriter (java.io.CharArrayWriter)3 StringReader (java.io.StringReader)3 DebugScoreRecord (com.airbnb.aerosolve.core.DebugScoreRecord)2 SimpleEntry (java.util.AbstractMap.SimpleEntry)2