Search in sources :

Example 1 with VectorToColumnsBatchOp

use of com.alibaba.alink.operator.batch.dataproc.format.VectorToColumnsBatchOp in project Alink by alibaba.

the class Chap19 method c_2.

static void c_2() throws Exception {
    MemSourceBatchOp source = new MemSourceBatchOp(CRIME_ROWS_DATA, CRIME_COL_NAMES);
    Pipeline std_pca = new Pipeline().add(new StandardScaler().setSelectedCols("murder", "rape", "robbery", "assault", "burglary", "larceny", "auto")).add(new PCA().setCalculationType(CalculationType.COV).setK(4).setSelectedCols("murder", "rape", "robbery", "assault", "burglary", "larceny", "auto").setPredictionCol(VECTOR_COL_NAME).enableLazyPrintModelInfo());
    std_pca.fit(source).transform(source).link(new VectorToColumnsBatchOp().setVectorCol(VECTOR_COL_NAME).setSchemaStr("prin1 double, prin2 double, prin3 double, prin4 double").setReservedCols("state")).lazyPrint(10, "state with principle components");
    BatchOperator.execute();
}
Also used : MemSourceBatchOp(com.alibaba.alink.operator.batch.source.MemSourceBatchOp) VectorToColumnsBatchOp(com.alibaba.alink.operator.batch.dataproc.format.VectorToColumnsBatchOp) StandardScaler(com.alibaba.alink.pipeline.dataproc.StandardScaler) Pipeline(com.alibaba.alink.pipeline.Pipeline) PCA(com.alibaba.alink.pipeline.feature.PCA)

Example 2 with VectorToColumnsBatchOp

use of com.alibaba.alink.operator.batch.dataproc.format.VectorToColumnsBatchOp in project Alink by alibaba.

the class Chap19 method c_1.

static void c_1() throws Exception {
    MemSourceBatchOp source = new MemSourceBatchOp(CRIME_ROWS_DATA, CRIME_COL_NAMES);
    source.lazyPrint(10, "Origin data");
    BatchOperator<?> pca_result = new PCA().setK(4).setSelectedCols("murder", "rape", "robbery", "assault", "burglary", "larceny", "auto").setPredictionCol(VECTOR_COL_NAME).enableLazyPrintModelInfo().fit(source).transform(source).link(new VectorToColumnsBatchOp().setVectorCol(VECTOR_COL_NAME).setSchemaStr("prin1 double, prin2 double, prin3 double, prin4 double").setReservedCols("state")).lazyPrint(10, "state with principle components");
    pca_result.select("state, prin1").orderBy("prin1", 100, false).lazyPrint(-1, "Order by prin1");
    pca_result.select("state, prin2").orderBy("prin2", 100, false).lazyPrint(-1, "Order by prin2");
    BatchOperator.execute();
}
Also used : MemSourceBatchOp(com.alibaba.alink.operator.batch.source.MemSourceBatchOp) VectorToColumnsBatchOp(com.alibaba.alink.operator.batch.dataproc.format.VectorToColumnsBatchOp) PCA(com.alibaba.alink.pipeline.feature.PCA)

Aggregations

VectorToColumnsBatchOp (com.alibaba.alink.operator.batch.dataproc.format.VectorToColumnsBatchOp)2 MemSourceBatchOp (com.alibaba.alink.operator.batch.source.MemSourceBatchOp)2 PCA (com.alibaba.alink.pipeline.feature.PCA)2 Pipeline (com.alibaba.alink.pipeline.Pipeline)1 StandardScaler (com.alibaba.alink.pipeline.dataproc.StandardScaler)1