use of com.alibaba.alink.operator.stream.feature.HashCrossFeatureStreamOp in project Alink by alibaba.
the class CrossFeatureTest method testHash.
@Test
public void testHash() throws Exception {
List<Row> expected = Arrays.asList(Row.of(1, "1.0", "1.0", 1.0, 1, VectorUtil.getVector("$36$21:1.0")), Row.of(2, "1.0", "1.0", 0.0, 1, VectorUtil.getVector("$36$3:1.0")), Row.of(3, "1.0", "0.0", 1.0, 1, VectorUtil.getVector("$36$33:1.0")), Row.of(4, "1.0", "0.0", 1.0, 1, VectorUtil.getVector("$36$33:1.0")), Row.of(5, "2.0", "3.0", null, 0, VectorUtil.getVector("$36$")), Row.of(6, "2.0", "3.0", 1.0, 0, VectorUtil.getVector("$36$16:1.0")), Row.of(7, "0.0", "1.0", 2.0, 0, VectorUtil.getVector("$36$3:1.0")), Row.of(8, "0.0", "1.0", 1.0, 0, VectorUtil.getVector("$36$8:1.0")));
StreamOperator<?> data = new MemSourceStreamOp(Arrays.asList(array), vecColNames);
HashCrossFeatureStreamOp hashCross = new HashCrossFeatureStreamOp().setNumFeatures(36).setSelectedCols("f0", "f1", "f2").setOutputCol("res").linkFrom(data);
CollectSinkStreamOp sink = new CollectSinkStreamOp().linkFrom(hashCross);
StreamOperator.execute();
assertListRowEqual(expected, sink.getAndRemoveValues(), 0);
}
Aggregations