Search in sources :

Example 16 with FeatureVector

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

the class DecisionTreeTransformTest method makeFeatureVector.

public FeatureVector makeFeatureVector(double x, double y) {
    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("x", x);
    map.put("y", y);
    floatFeatures.put("loc", map);
    FeatureVector featureVector = new FeatureVector();
    featureVector.setStringFeatures(stringFeatures);
    featureVector.setFloatFeatures(floatFeatures);
    return featureVector;
}
Also used : FeatureVector(com.airbnb.aerosolve.core.FeatureVector)

Example 17 with FeatureVector

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

the class DeleteFloatFeatureFamilyTransformTest method testEmptyFeatureVector.

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

Example 18 with FeatureVector

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

the class DeleteFloatFeatureFamilyTransformTest method makeFeatureVector.

public FeatureVector makeFeatureVector() {
    Map<String, Map<String, Double>> floatFeatures = new HashMap<>();
    Map<String, Double> family1 = new HashMap<>();
    family1.put("A", 1.0);
    family1.put("B", 2.0);
    Map<String, Double> family2 = new HashMap<>();
    family2.put("C", 3.0);
    family2.put("D", 4.0);
    Map<String, Double> family3 = new HashMap<>();
    family3.put("E", 5.0);
    family3.put("F", 6.0);
    Map<String, Double> family4 = new HashMap<>();
    family4.put("G", 7.0);
    family4.put("H", 8.0);
    floatFeatures.put("F1", family1);
    floatFeatures.put("F2", family2);
    floatFeatures.put("F3", family3);
    floatFeatures.put("F4", family4);
    FeatureVector featureVector = new FeatureVector();
    featureVector.setFloatFeatures(floatFeatures);
    return featureVector;
}
Also used : FeatureVector(com.airbnb.aerosolve.core.FeatureVector) HashMap(java.util.HashMap) Map(java.util.Map) HashMap(java.util.HashMap)

Example 19 with FeatureVector

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

the class DeleteStringFeatureFamilyTransformTest method testTransform.

@Test
public void testTransform() {
    Config config = ConfigFactory.parseString(makeConfig());
    Transform transform = TransformFactory.createTransform(config, "test_delete_string_feature_family");
    FeatureVector featureVector = makeFeatureVector();
    Map<String, Set<String>> stringFeatures = featureVector.getStringFeatures();
    assertNotNull(stringFeatures);
    assertTrue(stringFeatures.containsKey("strFeature1"));
    assertTrue(stringFeatures.containsKey("strFeature2"));
    assertTrue(stringFeatures.containsKey("strFeature3"));
    assertTrue(stringFeatures.containsKey("strFeature4"));
    assertEquals(4, stringFeatures.size());
    transform.doTransform(featureVector);
    assertNotNull(stringFeatures);
    assertFalse(stringFeatures.containsKey("strFeature1"));
    assertFalse(stringFeatures.containsKey("strFeature2"));
    assertFalse(stringFeatures.containsKey("strFeature3"));
    assertTrue(stringFeatures.containsKey("strFeature4"));
    assertEquals(1, stringFeatures.size());
}
Also used : FeatureVector(com.airbnb.aerosolve.core.FeatureVector) Set(java.util.Set) HashSet(java.util.HashSet) Config(com.typesafe.config.Config) Test(org.junit.Test)

Example 20 with FeatureVector

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

the class DeleteStringFeatureFamilyTransformTest method makeFeatureVector.

public FeatureVector makeFeatureVector() {
    Map<String, Set<String>> stringFeatures = new HashMap<>();
    Set<String> list1 = new HashSet<>();
    list1.add("I am a string in string feature 1");
    stringFeatures.put("strFeature1", list1);
    Set<String> list2 = new HashSet<>();
    list2.add("I am a string in string feature 2");
    stringFeatures.put("strFeature2", list2);
    Set<String> list3 = new HashSet<>();
    list3.add("I am a string in string feature 3");
    stringFeatures.put("strFeature3", list3);
    Set<String> list4 = new HashSet<>();
    list4.add("I am a string in string feature 4");
    stringFeatures.put("strFeature4", list4);
    FeatureVector featureVector = new FeatureVector();
    featureVector.setStringFeatures(stringFeatures);
    return featureVector;
}
Also used : FeatureVector(com.airbnb.aerosolve.core.FeatureVector) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) HashSet(java.util.HashSet)

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