Search in sources :

Example 1 with HashCrossFeatureStreamOp

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);
}
Also used : MemSourceStreamOp(com.alibaba.alink.operator.stream.source.MemSourceStreamOp) CollectSinkStreamOp(com.alibaba.alink.operator.stream.sink.CollectSinkStreamOp) Row(org.apache.flink.types.Row) HashCrossFeatureStreamOp(com.alibaba.alink.operator.stream.feature.HashCrossFeatureStreamOp) Test(org.junit.Test)

Aggregations

HashCrossFeatureStreamOp (com.alibaba.alink.operator.stream.feature.HashCrossFeatureStreamOp)1 CollectSinkStreamOp (com.alibaba.alink.operator.stream.sink.CollectSinkStreamOp)1 MemSourceStreamOp (com.alibaba.alink.operator.stream.source.MemSourceStreamOp)1 Row (org.apache.flink.types.Row)1 Test (org.junit.Test)1