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());
}
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);
}
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;
}
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);
}
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);
}
Aggregations