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();
}
Aggregations