Search in sources :

Example 1 with EqualWidthDiscretizerTrainBatchOp

use of com.alibaba.alink.operator.batch.feature.EqualWidthDiscretizerTrainBatchOp in project Alink by alibaba.

the class EqualWidthDiscretizerTest method testInitializer.

@Test
public void testInitializer() {
    EqualWidthDiscretizerModel model = new EqualWidthDiscretizerModel();
    Assert.assertEquals(model.getParams().size(), 0);
    EqualWidthDiscretizer op = new EqualWidthDiscretizer(new Params());
    Assert.assertEquals(op.getParams().size(), 0);
    BatchOperator<?> b = new EqualWidthDiscretizerTrainBatchOp();
    Assert.assertEquals(b.getParams().size(), 0);
    b = new EqualWidthDiscretizerTrainBatchOp(new Params());
    Assert.assertEquals(b.getParams().size(), 0);
    b = new EqualWidthDiscretizerPredictBatchOp();
    Assert.assertEquals(b.getParams().size(), 0);
    b = new EqualWidthDiscretizerPredictBatchOp(new Params());
    Assert.assertEquals(b.getParams().size(), 0);
    StreamOperator<?> s = new EqualWidthDiscretizerPredictStreamOp(b);
    Assert.assertEquals(s.getParams().size(), 0);
    s = new EqualWidthDiscretizerPredictStreamOp(b, new Params());
    Assert.assertEquals(s.getParams().size(), 0);
}
Also used : EqualWidthDiscretizerTrainBatchOp(com.alibaba.alink.operator.batch.feature.EqualWidthDiscretizerTrainBatchOp) EqualWidthDiscretizerPredictBatchOp(com.alibaba.alink.operator.batch.feature.EqualWidthDiscretizerPredictBatchOp) EqualWidthDiscretizerPredictStreamOp(com.alibaba.alink.operator.stream.feature.EqualWidthDiscretizerPredictStreamOp) Params(org.apache.flink.ml.api.misc.param.Params) Test(org.junit.Test)

Example 2 with EqualWidthDiscretizerTrainBatchOp

use of com.alibaba.alink.operator.batch.feature.EqualWidthDiscretizerTrainBatchOp in project Alink by alibaba.

the class EqualWidthDiscretizerTest method testException.

@Test
public void testException() throws Exception {
    thrown.expect(RuntimeException.class);
    NumSeqSourceBatchOp numSeqSourceBatchOp = new NumSeqSourceBatchOp(0, 10, "col0");
    EqualWidthDiscretizerTrainBatchOp op = new EqualWidthDiscretizerTrainBatchOp().setNumBuckets(5).setNumBucketsArray(5, 4).setSelectedCols("col0").linkFrom(numSeqSourceBatchOp);
    op.lazyPrintModelInfo();
    op = new EqualWidthDiscretizerTrainBatchOp().setNumBucketsArray(5).setSelectedCols("col0").linkFrom(numSeqSourceBatchOp);
    op.lazyCollect(new Consumer<List<Row>>() {

        @Override
        public void accept(List<Row> rows) {
            System.out.println(Arrays.toString(new EqualWidthDiscretizerModelInfoBatchOp.EqualWidthDiscretizerModelInfo(rows).getCutsArray("col0")));
        }
    });
}
Also used : NumSeqSourceBatchOp(com.alibaba.alink.operator.batch.source.NumSeqSourceBatchOp) EqualWidthDiscretizerTrainBatchOp(com.alibaba.alink.operator.batch.feature.EqualWidthDiscretizerTrainBatchOp) List(java.util.List) Row(org.apache.flink.types.Row) Test(org.junit.Test)

Aggregations

EqualWidthDiscretizerTrainBatchOp (com.alibaba.alink.operator.batch.feature.EqualWidthDiscretizerTrainBatchOp)2 Test (org.junit.Test)2 EqualWidthDiscretizerPredictBatchOp (com.alibaba.alink.operator.batch.feature.EqualWidthDiscretizerPredictBatchOp)1 NumSeqSourceBatchOp (com.alibaba.alink.operator.batch.source.NumSeqSourceBatchOp)1 EqualWidthDiscretizerPredictStreamOp (com.alibaba.alink.operator.stream.feature.EqualWidthDiscretizerPredictStreamOp)1 List (java.util.List)1 Params (org.apache.flink.ml.api.misc.param.Params)1 Row (org.apache.flink.types.Row)1