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