Search in sources :

Example 91 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 92 with FeatureVector

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

the class FloatLabelTransformTest method keepExistingLabel.

@Test
public void keepExistingLabel() {
    FloatLabelTransform transform = createTransform(FloatLabelTransform.MergeStrategy.SKIP);
    // fill in missing positive label
    FeatureVector featureVector1 = makeFeatureVector(1.0, null);
    transform.doTransform(featureVector1);
    assertEquals(-1, getLabel(featureVector1), 0.1);
    // fill in missing negative label
    FeatureVector featureVector2 = makeFeatureVector(10.0, null);
    transform.doTransform(featureVector2);
    assertEquals(1, getLabel(featureVector2), 0.1);
    // preserve positive label
    FeatureVector featureVector3 = makeFeatureVector(1.0, 1.0);
    transform.doTransform(featureVector3);
    assertEquals(1, getLabel(featureVector3), 0.1);
    // preserve negative label
    FeatureVector featureVector4 = makeFeatureVector(10.0, -1.0);
    transform.doTransform(featureVector4);
    assertEquals(-1, getLabel(featureVector4), 0.1);
}
Also used : FeatureVector(com.airbnb.aerosolve.core.FeatureVector) Test(org.junit.Test)

Example 93 with FeatureVector

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

the class FloatLabelTransformTest method makeFeatureVector.

private FeatureVector makeFeatureVector(Double value, Double label) {
    Map<String, Map<String, Double>> floatFeatures = new HashMap<>();
    if (value != null) {
        Map<String, Double> map = new HashMap<>();
        map.put("50th", value);
        floatFeatures.put("DECILES", map);
    }
    if (label != null) {
        Map<String, Double> map = new HashMap<>();
        map.put("", label);
        floatFeatures.put("LABEL", map);
    }
    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 94 with FeatureVector

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

the class FloatLabelTransformTest method handleMissingFeature.

@Test
public void handleMissingFeature() {
    FloatLabelTransform transform = createTransform(FloatLabelTransform.MergeStrategy.OVERRIDE);
    // keep current label even though we could overwrite
    FeatureVector featureVector1 = makeFeatureVector(null, 1.0);
    transform.doTransform(featureVector1);
    assertEquals(1, getLabel(featureVector1), 0.1);
}
Also used : FeatureVector(com.airbnb.aerosolve.core.FeatureVector) Test(org.junit.Test)

Example 95 with FeatureVector

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

the class FloatLabelTransformTest method keepPositiveLabel.

@Test
public void keepPositiveLabel() {
    FloatLabelTransform transform = createTransform(FloatLabelTransform.MergeStrategy.OVERRIDE_NEGATIVE);
    // fill in missing positive label
    FeatureVector featureVector1 = makeFeatureVector(1.0, null);
    transform.doTransform(featureVector1);
    assertEquals(-1, getLabel(featureVector1), 0.1);
    // fill in missing negative label
    FeatureVector featureVector2 = makeFeatureVector(10.0, null);
    transform.doTransform(featureVector2);
    assertEquals(1, getLabel(featureVector2), 0.1);
    // preserve positive label
    FeatureVector featureVector3 = makeFeatureVector(1.0, 1.0);
    transform.doTransform(featureVector3);
    assertEquals(1, getLabel(featureVector3), 0.1);
    // overwrite negative label
    FeatureVector featureVector4 = makeFeatureVector(10.0, -1.0);
    transform.doTransform(featureVector4);
    assertEquals(1, getLabel(featureVector4), 0.1);
}
Also used : FeatureVector(com.airbnb.aerosolve.core.FeatureVector) 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