Search in sources :

Example 1 with MaxAbsScalerPredictStreamOp

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

the class MaxAbsTest method test.

@Test
public void test() throws Exception {
    BatchOperator batchData = new TableSourceBatchOp(GenerateData.getBatchTable());
    StreamOperator streamData = new TableSourceStreamOp(GenerateData.getStreamTable());
    MaxAbsScalerModel model = new MaxAbsScaler().setSelectedCols("f0", "f1").setOutputCols("f0_1", "f1_1").fit(batchData);
    model.transform(batchData).lazyCollect();
    model.transform(streamData).print();
    MaxAbsScalerTrainBatchOp op = new MaxAbsScalerTrainBatchOp().setSelectedCols("f0", "f1").linkFrom(batchData);
    List<Row> rows = new MaxAbsScalerPredictBatchOp().linkFrom(op, batchData).collect();
    rows.sort(StandardScalerTest.compare);
    assertEquals(rows.get(0), Row.of(null, null));
    StandardScalerTest.assertRow(rows.get(1), Row.of(-0.25, -1.));
    StandardScalerTest.assertRow(rows.get(2), Row.of(0.25, 0.666));
    StandardScalerTest.assertRow(rows.get(3), Row.of(1.0, 0.6666));
    new MaxAbsScalerPredictStreamOp(op).linkFrom(streamData).print();
    StreamOperator.execute();
}
Also used : MaxAbsScaler(com.alibaba.alink.pipeline.dataproc.MaxAbsScaler) MaxAbsScalerPredictStreamOp(com.alibaba.alink.operator.stream.dataproc.MaxAbsScalerPredictStreamOp) MaxAbsScalerModel(com.alibaba.alink.pipeline.dataproc.MaxAbsScalerModel) 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) Test(org.junit.Test)

Aggregations

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 MaxAbsScalerPredictStreamOp (com.alibaba.alink.operator.stream.dataproc.MaxAbsScalerPredictStreamOp)1 TableSourceStreamOp (com.alibaba.alink.operator.stream.source.TableSourceStreamOp)1 MaxAbsScaler (com.alibaba.alink.pipeline.dataproc.MaxAbsScaler)1 MaxAbsScalerModel (com.alibaba.alink.pipeline.dataproc.MaxAbsScalerModel)1 Row (org.apache.flink.types.Row)1 Test (org.junit.Test)1