use of com.alibaba.alink.operator.stream.dataproc.vector.VectorMaxAbsScalerPredictStreamOp in project Alink by alibaba.
the class VectorMaxAbsTest method test.
@Test
public void test() throws Exception {
BatchOperator batchData = new TableSourceBatchOp(GenerateData.getDenseBatch());
StreamOperator streamData = new TableSourceStreamOp(GenerateData.getDenseStream());
VectorMaxAbsScalerTrainBatchOp op = new VectorMaxAbsScalerTrainBatchOp().setSelectedCol("vec").linkFrom(batchData);
List<Row> rows = new VectorMaxAbsScalerPredictBatchOp().setOutputCol("res").linkFrom(op, batchData).collect();
VectorStandardScalerTest.assertDv(VectorUtil.getDenseVector(rows.get(0).getField(1)), new DenseVector(new double[] { 0.25, 0.6666 }));
VectorStandardScalerTest.assertDv(VectorUtil.getDenseVector(rows.get(1).getField(1)), new DenseVector(new double[] { -0.25, -1. }));
VectorStandardScalerTest.assertDv(VectorUtil.getDenseVector(rows.get(2).getField(1)), new DenseVector(new double[] { 1., 0.6666 }));
new VectorMaxAbsScalerPredictStreamOp(op).setOutputCol("res").linkFrom(streamData).print();
StreamOperator.execute();
}
Aggregations