use of com.airbnb.aerosolve.core.ModelRecord in project aerosolve by airbnb.
the class SplineTest method testSplineModelRecordConstructor.
@Test
public void testSplineModelRecordConstructor() {
ModelRecord record = new ModelRecord();
record.setFeatureFamily("TEST");
record.setFeatureName("a");
record.setMinVal(1.0);
record.setMaxVal(3.0);
List<Double> weightVec = new ArrayList<Double>();
weightVec.add(5.0);
weightVec.add(10.0);
weightVec.add(-20.0);
record.setWeightVector(weightVec);
Spline spline = new Spline(record);
testSpline(spline, 0.1f);
}
use of com.airbnb.aerosolve.core.ModelRecord in project aerosolve by airbnb.
the class SplineTest method testSplineToModelRecord.
@Test
public void testSplineToModelRecord() {
float[] weights = { 5.0f, 10.0f, -20.0f };
Spline spline = new Spline(1.0f, 3.0f, weights);
ModelRecord record = spline.toModelRecord("family", "name");
assertEquals(record.getFeatureFamily(), "family");
assertEquals(record.getFeatureName(), "name");
List<Double> weightVector = record.getWeightVector();
assertEquals(5.0f, weightVector.get(0).floatValue(), 0.01f);
assertEquals(10.0f, weightVector.get(1).floatValue(), 0.01f);
assertEquals(-20.0f, weightVector.get(2).floatValue(), 0.01f);
assertEquals(1.0f, record.getMinVal(), 0.01f);
assertEquals(3.0f, record.getMaxVal(), 0.01f);
}
use of com.airbnb.aerosolve.core.ModelRecord in project aerosolve by airbnb.
the class DecisionTreeTransformTest method makeTree.
/*
* XOR like decision regions
*
* x = 2
* |
* -0.5 | 1.0
* |-------- y = 1
* -------- y = 0
* |
* 0.25 | -0.75
* |
*/
public DecisionTreeModel makeTree() {
ArrayList<ModelRecord> records = new ArrayList<>();
DecisionTreeModel tree = new DecisionTreeModel();
tree.setStumps(records);
// 0 - an x split at 2
ModelRecord record = new ModelRecord();
record.setFeatureFamily("loc");
record.setFeatureName("x");
record.setThreshold(2.0);
record.setLeftChild(1);
record.setRightChild(2);
records.add(record);
// 1 - a y split at 0
record = new ModelRecord();
record.setFeatureFamily("loc");
record.setFeatureName("y");
record.setThreshold(0.0);
record.setLeftChild(3);
record.setRightChild(4);
records.add(record);
// 2 - a y split at 1
record = new ModelRecord();
record.setFeatureFamily("loc");
record.setFeatureName("y");
record.setThreshold(1.0);
record.setLeftChild(5);
record.setRightChild(6);
records.add(record);
// 3 a leaf
record = new ModelRecord();
record.setFeatureWeight(0.25);
records.add(record);
// 4 a leaf
record = new ModelRecord();
record.setFeatureWeight(-0.5);
records.add(record);
// 5 a leaf
record = new ModelRecord();
record.setFeatureWeight(-0.75);
records.add(record);
// 6 a leaf
record = new ModelRecord();
record.setFeatureWeight(1.0);
records.add(record);
return tree;
}
use of com.airbnb.aerosolve.core.ModelRecord in project aerosolve by airbnb.
the class SupportVector method toModelRecord.
public ModelRecord toModelRecord() {
ModelRecord rec = new ModelRecord();
rec.setScale(scale);
rec.setFunctionForm(form);
ArrayList<Double> weightVector = new ArrayList<>();
for (int i = 0; i < floatVector.getValues().length; i++) {
weightVector.add((double) floatVector.getValues()[i]);
}
rec.setWeightVector(weightVector);
rec.setFeatureWeight(weight);
return rec;
}
use of com.airbnb.aerosolve.core.ModelRecord in project aerosolve by airbnb.
the class LinearTest method testLinearModelRecordConstructor.
@Test
public void testLinearModelRecordConstructor() {
ModelRecord record = new ModelRecord();
record.setFeatureFamily("TEST");
record.setFeatureName("a");
List<Double> weightVec = new ArrayList<>();
weightVec.add(0.2);
weightVec.add(1.5);
record.setWeightVector(weightVec);
record.setMinVal(-6.0f);
record.setMaxVal(5.0f);
Linear linearFunc = new Linear(record);
testLinear(linearFunc);
}
Aggregations