Search in sources :

Example 21 with FeatureVector

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

the class DivideTransformTest method testTransformWithKeys.

@Test
public void testTransformWithKeys() {
    Config config = ConfigFactory.parseString(makeConfigWithKeys());
    Transform transform = TransformFactory.createTransform(config, "test_divide");
    FeatureVector featureVector = TransformTestingHelper.makeFeatureVector();
    transform.doTransform(featureVector);
    Map<String, Set<String>> stringFeatures = featureVector.getStringFeatures();
    assertTrue(stringFeatures.size() == 1);
    Map<String, Double> out = featureVector.floatFeatures.get("bar");
    for (Map.Entry<String, Double> entry : out.entrySet()) {
        log.info(entry.getKey() + "=" + entry.getValue());
    }
    assertTrue(out.size() == 3);
    // the existing features under the family "bar" should not be deleted
    assertEquals(1.0, out.get("bar_fv"), 0.1);
    assertEquals(37.7 / 1.6, out.get("lat-d-foo"), 0.1);
    assertEquals(40.0 / 1.6, out.get("long-d-foo"), 0.1);
}
Also used : FeatureVector(com.airbnb.aerosolve.core.FeatureVector) Config(com.typesafe.config.Config) Test(org.junit.Test)

Example 22 with FeatureVector

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

the class DivideTransformTest method testEmptyFeatureVector.

@Test
public void testEmptyFeatureVector() {
    Config config = ConfigFactory.parseString(makeConfigWithKeys());
    Transform transform = TransformFactory.createTransform(config, "test_divide");
    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 23 with FeatureVector

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

the class FloatFamilyCrossToTwoDDenseTransformTest method testEmptyFeatureVector.

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

Example 24 with FeatureVector

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

the class FloatToDenseTransformTest method makeFeatureVectorMissFamily.

public static FeatureVector makeFeatureVectorMissFamily() {
    Map<String, Map<String, Double>> floatFeatures = new HashMap<>();
    Map<String, Double> floatFeature1 = new HashMap<>();
    floatFeature1.put("x", 50.0);
    floatFeature1.put("y", 1.3);
    floatFeature1.put("s", 2000.0);
    floatFeatures.put("floatFeature1", floatFeature1);
    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 25 with FeatureVector

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);
}
Also used : FeatureVector(com.airbnb.aerosolve.core.FeatureVector) List(java.util.List) 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