Search in sources :

Example 1 with VectorMinMaxScalerPredictStreamOp

use of com.alibaba.alink.operator.stream.dataproc.vector.VectorMinMaxScalerPredictStreamOp in project Alink by alibaba.

the class VectorMinMaxTest method test.

@Test
public void test() throws Exception {
    BatchOperator batchData = new TableSourceBatchOp(GenerateData.getDenseBatch());
    StreamOperator streamData = new TableSourceStreamOp(GenerateData.getDenseStream());
    VectorMinMaxScalerTrainBatchOp op = new VectorMinMaxScalerTrainBatchOp().setSelectedCol("vec").linkFrom(batchData);
    List<Row> rows = new VectorMinMaxScalerPredictBatchOp().linkFrom(op, batchData).collect();
    assertEquals(rows.get(0).getField(0), new DenseVector(new double[] { 0.4, 1.0 }));
    assertEquals(rows.get(1), Row.of(new DenseVector(new double[] { 0., 0.0 })));
    assertEquals(rows.get(2), Row.of(new DenseVector(new double[] { 1.0, 1.0 })));
    new VectorMinMaxScalerPredictStreamOp(op).linkFrom(streamData).print();
    StreamOperator.execute();
}
Also used : VectorMinMaxScalerPredictStreamOp(com.alibaba.alink.operator.stream.dataproc.vector.VectorMinMaxScalerPredictStreamOp) 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) 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 VectorMinMaxScalerPredictStreamOp (com.alibaba.alink.operator.stream.dataproc.vector.VectorMinMaxScalerPredictStreamOp)1 TableSourceStreamOp (com.alibaba.alink.operator.stream.source.TableSourceStreamOp)1 Row (org.apache.flink.types.Row)1 Test (org.junit.Test)1