Search in sources :

Example 6 with Pipeline

use of com.alibaba.alink.pipeline.Pipeline in project Alink by alibaba.

the class SoftmaxTest method pipelineTest1.

@Test
public void pipelineTest1() {
    BatchOperator<?> vecmdata = new MemSourceBatchOp(Arrays.asList(vecrows), veccolNames);
    Pipeline pl = new Pipeline().add(softmax).add(vsoftmax).add(svsoftmax).add(vssoftmax);
    PipelineModel modelm = pl.fit(vecmdata);
    List<Row> data = modelm.transform(vecmdata).select(new String[] { "label", "predLr", "vpredLr", "svpredLr" }).collect();
    for (Row row : data) {
        for (int i = 1; i < 3; ++i) {
            Assert.assertEquals(row.getField(0), row.getField(i));
        }
    }
}
Also used : MemSourceBatchOp(com.alibaba.alink.operator.batch.source.MemSourceBatchOp) Row(org.apache.flink.types.Row) Pipeline(com.alibaba.alink.pipeline.Pipeline) PipelineModel(com.alibaba.alink.pipeline.PipelineModel) Test(org.junit.Test)

Example 7 with Pipeline

use of com.alibaba.alink.pipeline.Pipeline in project Alink by alibaba.

the class RandomForestTrainBatchOpTest method testCartPipeline.

@Test
public void testCartPipeline() throws Exception {
    Cart cart = new Cart().setFeatureCols(featureColNames).setCategoricalCols(categoricalColNames).setLabelCol(labelColName).setPredictionCol("cart_test_result").setPredictionDetailCol("cart_test_detail");
    Pipeline pipeline = new Pipeline().add(cart);
    BatchOperator<?> output = pipeline.fit(input).transform(input);
    output.lazyPrint(-1);
    BatchOperator<?> output1 = BatchOperator.fromTable(output.getOutputTable());
    output1.lazyPrint(-1);
    AlgoOperator<?> outputStream = pipeline.fit(input).transform(inputStream);
    outputStream.print();
    MLEnvironmentFactory.getDefault().getStreamExecutionEnvironment().execute();
}
Also used : Cart(com.alibaba.alink.pipeline.classification.Cart) Pipeline(com.alibaba.alink.pipeline.Pipeline) Test(org.junit.Test)

Example 8 with Pipeline

use of com.alibaba.alink.pipeline.Pipeline in project Alink by alibaba.

the class RandomForestTrainBatchOpTest method testId3Pipeline.

@Test
public void testId3Pipeline() throws Exception {
    Id3 id3 = new Id3().setFeatureCols(featureColNames).setCategoricalCols(categoricalColNames).setLabelCol(labelColName).setPredictionCol("id3_test_result").setPredictionDetailCol("id3_test_detail");
    Pipeline pipeline = new Pipeline().add(id3);
    BatchOperator<?> output = pipeline.fit(input).transform(input);
    output.lazyPrint(-1);
    BatchOperator<?> output1 = BatchOperator.fromTable(output.getOutputTable());
    output1.lazyPrint(-1);
    StreamOperator<?> outputStream = pipeline.fit(input).transform(inputStream);
    outputStream.print();
    MLEnvironmentFactory.getDefault().getStreamExecutionEnvironment().execute();
}
Also used : Id3(com.alibaba.alink.pipeline.classification.Id3) Pipeline(com.alibaba.alink.pipeline.Pipeline) Test(org.junit.Test)

Example 9 with Pipeline

use of com.alibaba.alink.pipeline.Pipeline in project Alink by alibaba.

the class JsonValueBatchOpTest method test3.

@Test
public void test3() throws Exception {
    Row[] testArray = new Row[] { Row.of("{\"ak\":1,\"dd\":1}") };
    String[] colnames = new String[] { "jsoncol" };
    MemSourceBatchOp inOp = new MemSourceBatchOp(Arrays.asList(testArray), colnames);
    List<Row> result = (new Pipeline().add(new JsonValue().setSkipFailed(true).setOutputColTypes(new String[] { "string", "string" }).setSelectedCol("jsoncol").setOutputCols(new String[] { "jsonval", "jv" }).setJsonPath("$.ak", "$.ck"))).fit(inOp).transform(inOp).collect();
    Assert.assertNull(result.get(0).getField(2));
}
Also used : MemSourceBatchOp(com.alibaba.alink.operator.batch.source.MemSourceBatchOp) JsonValue(com.alibaba.alink.pipeline.dataproc.JsonValue) Row(org.apache.flink.types.Row) Pipeline(com.alibaba.alink.pipeline.Pipeline) Test(org.junit.Test)

Example 10 with Pipeline

use of com.alibaba.alink.pipeline.Pipeline in project Alink by alibaba.

the class LogisticRegressionMixVecTest method batchMixVecTest5.

@Test
public void batchMixVecTest5() {
    BatchOperator<?> trainData = (BatchOperator<?>) getData();
    Pipeline pipeline = new Pipeline().add(new LogisticRegression().setVectorCol("svec").setWithIntercept(false).setStandardization(false).setLabelCol("labels").setPredictionCol("pred"));
    PipelineModel model = pipeline.fit(trainData);
    model.transform(trainData).collect();
}
Also used : LogisticRegression(com.alibaba.alink.pipeline.classification.LogisticRegression) BatchOperator(com.alibaba.alink.operator.batch.BatchOperator) Pipeline(com.alibaba.alink.pipeline.Pipeline) PipelineModel(com.alibaba.alink.pipeline.PipelineModel) Test(org.junit.Test)

Aggregations

Pipeline (com.alibaba.alink.pipeline.Pipeline)63 Test (org.junit.Test)38 PipelineModel (com.alibaba.alink.pipeline.PipelineModel)34 LogisticRegression (com.alibaba.alink.pipeline.classification.LogisticRegression)20 Row (org.apache.flink.types.Row)18 BatchOperator (com.alibaba.alink.operator.batch.BatchOperator)16 MemSourceBatchOp (com.alibaba.alink.operator.batch.source.MemSourceBatchOp)16 VectorAssembler (com.alibaba.alink.pipeline.dataproc.vector.VectorAssembler)11 AkSourceBatchOp (com.alibaba.alink.operator.batch.source.AkSourceBatchOp)10 CollectSinkStreamOp (com.alibaba.alink.operator.stream.sink.CollectSinkStreamOp)9 EvalBinaryClassBatchOp (com.alibaba.alink.operator.batch.evaluation.EvalBinaryClassBatchOp)8 MemSourceStreamOp (com.alibaba.alink.operator.stream.source.MemSourceStreamOp)7 File (java.io.File)5 ArrayList (java.util.ArrayList)5 EvalMultiClassBatchOp (com.alibaba.alink.operator.batch.evaluation.EvalMultiClassBatchOp)4 StandardScaler (com.alibaba.alink.pipeline.dataproc.StandardScaler)4 Stopwatch (com.alibaba.alink.common.utils.Stopwatch)3 CsvSourceBatchOp (com.alibaba.alink.operator.batch.source.CsvSourceBatchOp)3 KMeans (com.alibaba.alink.pipeline.clustering.KMeans)3 VectorToTensor (com.alibaba.alink.pipeline.dataproc.VectorToTensor)3