Search in sources :

Example 1 with VectorMaxAbsScalerPredictStreamOp

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();
}
Also used : TableSourceStreamOp(com.alibaba.alink.operator.stream.source.TableSourceStreamOp) Row(org.apache.flink.types.Row) TableSourceBatchOp(com.alibaba.alink.operator.batch.source.TableSourceBatchOp) StreamOperator(com.alibaba.alink.operator.stream.StreamOperator) BatchOperator(com.alibaba.alink.operator.batch.BatchOperator) DenseVector(com.alibaba.alink.common.linalg.DenseVector) VectorMaxAbsScalerPredictStreamOp(com.alibaba.alink.operator.stream.dataproc.vector.VectorMaxAbsScalerPredictStreamOp) Test(org.junit.Test)

Aggregations

DenseVector (com.alibaba.alink.common.linalg.DenseVector)1 BatchOperator (com.alibaba.alink.operator.batch.BatchOperator)1 TableSourceBatchOp (com.alibaba.alink.operator.batch.source.TableSourceBatchOp)1 StreamOperator (com.alibaba.alink.operator.stream.StreamOperator)1 VectorMaxAbsScalerPredictStreamOp (com.alibaba.alink.operator.stream.dataproc.vector.VectorMaxAbsScalerPredictStreamOp)1 TableSourceStreamOp (com.alibaba.alink.operator.stream.source.TableSourceStreamOp)1 Row (org.apache.flink.types.Row)1 Test (org.junit.Test)1