Search in sources :

Example 1 with FlattenMTableBatchOp

use of com.alibaba.alink.operator.batch.dataproc.FlattenMTableBatchOp in project Alink by alibaba.

the class ProphetBatchOpTest method test2.

@Ignore
@Test
public void test2() throws Exception {
    AlinkGlobalConfiguration.setPrintProcessInfo(true);
    Row[] rowsData = new Row[] { Row.of("20210501", 0.1, "a1"), Row.of("20210502", 0.2, "a1"), Row.of("20210503", 0.3, "a1"), Row.of("20210504", 0.4, "a1"), Row.of("20210505", 0.5, "a1"), Row.of("20210506", 0.6, "a1"), Row.of("20210507", 0.7, "a1"), Row.of("20210508", 0.8, "a1"), Row.of("20210509", 0.9, "a1") };
    String[] colNames = new String[] { "ds", "f1", "f2" };
    // train batch model.
    MemSourceBatchOp source = new MemSourceBatchOp(Arrays.asList(rowsData), colNames);
    source.select("to_timestamp(ds, 'yyyyMMdd') as ds, f1 as val, f2 as id").link(new GroupByBatchOp().setGroupByPredicate("id").setSelectClause("id, mtable_agg(ds, val) as data")).link(new ProphetBatchOp().setValueCol("data").setPredictionCol("pred").setPredictNum(12).setUncertaintySamples(0).setReservedCols("id").setPythonEnv("file:///Users/ning.cain/soft/miniforge3/envs/py39t/")).link(new FlattenMTableBatchOp().setReservedCols("id").setSelectedCol("pred").setSchemaStr("ds string, val double")).print();
}
Also used : MemSourceBatchOp(com.alibaba.alink.operator.batch.source.MemSourceBatchOp) FlattenMTableBatchOp(com.alibaba.alink.operator.batch.dataproc.FlattenMTableBatchOp) GroupByBatchOp(com.alibaba.alink.operator.batch.sql.GroupByBatchOp) Row(org.apache.flink.types.Row) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

FlattenMTableBatchOp (com.alibaba.alink.operator.batch.dataproc.FlattenMTableBatchOp)1 MemSourceBatchOp (com.alibaba.alink.operator.batch.source.MemSourceBatchOp)1 GroupByBatchOp (com.alibaba.alink.operator.batch.sql.GroupByBatchOp)1 Row (org.apache.flink.types.Row)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1