use of com.alibaba.alink.pipeline.Pipeline in project Alink by alibaba.
the class LogisticRegressionMixVecTest method batchMixVecTest13.
@Test
public void batchMixVecTest13() {
BatchOperator<?> trainData = (BatchOperator<?>) getData();
Pipeline pipeline = new Pipeline().add(new VectorAssembler().setSelectedCols(new String[] { "svec", "vec", "f0", "f1", "f2", "f3" }).setOutputCol("allvec")).add(new LogisticRegression().setVectorCol("allvec").setWithIntercept(false).setStandardization(false).setLabelCol("labels").setReservedCols(new String[] { "labels" }).setPredictionCol("pred"));
PipelineModel model = pipeline.fit(trainData);
model.transform(trainData).collect();
}
use of com.alibaba.alink.pipeline.Pipeline in project Alink by alibaba.
the class LogisticRegressionMixVecTest method batchMixVecTest4.
@Test
public void batchMixVecTest4() {
BatchOperator<?> trainData = (BatchOperator<?>) getData();
Pipeline pipeline = new Pipeline().add(new LogisticRegression().setVectorCol("vec").setWithIntercept(true).setStandardization(false).setLabelCol("labels").setPredictionCol("pred"));
PipelineModel model = pipeline.fit(trainData);
model.transform(trainData).collect();
}
use of com.alibaba.alink.pipeline.Pipeline in project Alink by alibaba.
the class LogisticRegressionMixVecTest method batchMixVecTest11.
@Test
public void batchMixVecTest11() {
BatchOperator<?> trainData = (BatchOperator<?>) getData();
Pipeline pipeline = new Pipeline().add(new VectorAssembler().setSelectedCols(new String[] { "svec", "vec", "f0", "f1", "f2", "f3" }).setOutputCol("allvec")).add(new LogisticRegression().setVectorCol("allvec").setWithIntercept(true).setReservedCols(new String[] { "labels" }).setStandardization(false).setLabelCol("labels").setPredictionCol("pred"));
PipelineModel model = pipeline.fit(trainData);
model.transform(trainData).collect();
}
use of com.alibaba.alink.pipeline.Pipeline in project Alink by alibaba.
the class LogisticRegressionMixVecTest method batchMixVecTest7.
@Test
public void batchMixVecTest7() {
BatchOperator<?> trainData = (BatchOperator<?>) getData();
Pipeline pipeline = new Pipeline().add(new LogisticRegression().setVectorCol("svec").setWithIntercept(false).setStandardization(true).setLabelCol("labels").setPredictionCol("pred"));
PipelineModel model = pipeline.fit(trainData);
model.transform(trainData).collect();
}
use of com.alibaba.alink.pipeline.Pipeline in project Alink by alibaba.
the class IsotonicRegressionTest method testIsotonicReg.
@Test
public void testIsotonicReg() throws Exception {
Table data = MLEnvironmentFactory.getDefault().createBatchTable(rows, new String[] { "id", "feature", "label" });
Table dataStream = MLEnvironmentFactory.getDefault().createStreamTable(rows, new String[] { "id", "feature", "label" });
IsotonicRegression op = new IsotonicRegression().setFeatureCol("feature").setLabelCol("label").setPredictionCol("result");
PipelineModel model = new Pipeline().add(op).fit(data);
BatchOperator<?> res = model.transform(new TableSourceBatchOp(data));
List<Row> list = res.select(new String[] { "id", "result" }).collect();
double[] actual = new double[] { 0.66, 0.75, 0.75, 0.75, 0.5, 0.5, 0.75, 0.66, 0.66, 0.75, 0.5, 0.5, 0.5, 0.5, 0.75 };
for (int i = 0; i < actual.length; i++) {
Assert.assertEquals((Double) list.get(i).getField(1), actual[(int) list.get(i).getField(0)], 0.01);
}
// StreamOperator<?> resStream = model.transform(new TableSourceStreamOp(dataStream));
// resStream.print();
// MLEnvironmentFactory.getDefault().getStreamExecutionEnvironment().execute();
}
Aggregations