use of com.alibaba.alink.pipeline.dataproc.vector.VectorPolynomialExpand in project Alink by alibaba.
the class VectorPolynomialExpandTest method test.
@Test
public void test() throws Exception {
Row[] rows = new Row[] { Row.of("3.0, 4.0") };
BatchOperator batchData = new MemSourceBatchOp(rows, new String[] { "vec" });
StreamOperator streamData = new MemSourceStreamOp(rows, new String[] { "vec" });
new VectorPolynomialExpandBatchOp().setDegree(2).setOutputCol("outv").setSelectedCol("vec").linkFrom(batchData);
new VectorPolynomialExpandStreamOp().setDegree(2).setOutputCol("outv").setSelectedCol("vec").linkFrom(streamData);
VectorPolynomialExpand pipeline = new VectorPolynomialExpand().setDegree(2).setOutputCol("outv").setSelectedCol("vec");
pipeline.transform(batchData).collect();
pipeline.transform(streamData).print();
StreamOperator.execute();
}
use of com.alibaba.alink.pipeline.dataproc.vector.VectorPolynomialExpand in project Alink by alibaba.
the class Chap08 method c_8.
static void c_8() throws Exception {
BatchOperator<?> train_data = new AkSourceBatchOp().setFilePath(DATA_DIR + TRAIN_FILE);
BatchOperator<?> test_data = new AkSourceBatchOp().setFilePath(DATA_DIR + TEST_FILE);
PipelineModel featureExpand = new Pipeline().add(new VectorAssembler().setSelectedCols(FEATURE_COL_NAMES).setOutputCol(VEC_COL_NAME + "_0")).add(new VectorPolynomialExpand().setSelectedCol(VEC_COL_NAME + "_0").setOutputCol(VEC_COL_NAME).setDegree(2)).fit(train_data);
train_data = featureExpand.transform(train_data);
test_data = featureExpand.transform(test_data);
train_data.lazyPrint(1);
new LinearSvm().setVectorCol(VEC_COL_NAME).setLabelCol(LABEL_COL_NAME).setPredictionCol(PREDICTION_COL_NAME).setPredictionDetailCol(PRED_DETAIL_COL_NAME).fit(train_data).transform(test_data).link(new EvalBinaryClassBatchOp().setPositiveLabelValueString("1").setLabelCol(LABEL_COL_NAME).setPredictionDetailCol(PRED_DETAIL_COL_NAME).lazyPrintMetrics("LinearSVM"));
new LogisticRegression().setVectorCol(VEC_COL_NAME).setLabelCol(LABEL_COL_NAME).setPredictionCol(PREDICTION_COL_NAME).setPredictionDetailCol(PRED_DETAIL_COL_NAME).fit(train_data).transform(test_data).link(new EvalBinaryClassBatchOp().setPositiveLabelValueString("1").setLabelCol(LABEL_COL_NAME).setPredictionDetailCol(PRED_DETAIL_COL_NAME).lazyPrintMetrics("LogisticRegression"));
new LogisticRegression().setOptimMethod(OptimMethod.Newton).setVectorCol(VEC_COL_NAME).setLabelCol(LABEL_COL_NAME).setPredictionCol(PREDICTION_COL_NAME).setPredictionDetailCol(PRED_DETAIL_COL_NAME).fit(train_data).transform(test_data).link(new EvalBinaryClassBatchOp().setPositiveLabelValueString("1").setLabelCol(LABEL_COL_NAME).setPredictionDetailCol(PRED_DETAIL_COL_NAME).lazyPrintMetrics("LogisticRegression + OptimMethod.Newton"));
BatchOperator.execute();
}
Aggregations