use of com.alibaba.alink.operator.batch.statistics.CorrelationBatchOp in project Alink by alibaba.
the class Chap12 method c_2.
static void c_2() throws Exception {
CsvSourceBatchOp source = new CsvSourceBatchOp().setFilePath(DATA_DIR + ORIGIN_FILE).setSchemaStr(SCHEMA_STRING);
source.lazyPrint(5, "origin file").lazyPrintStatistics("stat of origin file").link(new CorrelationBatchOp().setSelectedCols(FEATURE_COL_NAMES).lazyPrintCorrelation());
source.groupBy(LABEL_COL_NAME, LABEL_COL_NAME + ", COUNT(*) AS cnt").lazyPrint(-1);
BatchOperator.execute();
Utils.splitTrainTestIfNotExist(source, DATA_DIR + TRAIN_FILE, DATA_DIR + TEST_FILE, 0.9);
}
use of com.alibaba.alink.operator.batch.statistics.CorrelationBatchOp in project Alink by alibaba.
the class Chap08 method c_3_2.
static void c_3_2() throws Exception {
CsvSourceBatchOp source = new CsvSourceBatchOp().setFilePath(DATA_DIR + ORIGIN_FILE).setSchemaStr(SCHEMA_STRING);
CorrelationResult correlation = new CorrelationBatchOp().linkFrom(source).collectCorrelation();
String[] colNames = correlation.getColNames();
System.out.print("Correlation of " + colNames[0] + " with " + colNames[1]);
System.out.println(" is " + correlation.getCorrelation()[0][1]);
System.out.println(correlation.getCorrelationMatrix());
source.link(new CorrelationBatchOp().lazyCollectCorrelation(new Consumer<CorrelationResult>() {
@Override
public void accept(CorrelationResult correlationResult) {
String[] colNames = correlationResult.getColNames();
System.out.print("Correlation of " + colNames[0] + " with " + colNames[1]);
System.out.println(" is " + correlationResult.getCorrelation()[0][1]);
System.out.println(correlationResult.getCorrelationMatrix());
}
}));
source.link(new CorrelationBatchOp().lazyPrintCorrelation("< Pearson Correlation >"));
source.link(new CorrelationBatchOp().setMethod(Method.SPEARMAN).lazyPrintCorrelation("< Spearman Correlation >"));
BatchOperator.execute();
}
use of com.alibaba.alink.operator.batch.statistics.CorrelationBatchOp in project Alink by alibaba.
the class Chap11 method c_1.
static void c_1() throws Exception {
BatchOperator<?> source = getSource();
source.lazyPrint(10, "origin file");
source.lazyPrintStatistics("stat of origin file");
source.link(new CorrelationBatchOp().setSelectedCols("user_id", "brand_id", "type").lazyPrintCorrelation());
source.select("min(ts) AS min_ts, max(ts) AS max_ts").lazyPrint(-1);
source.groupBy("type", "type, COUNT(*) AS cnt").lazyPrint(-1);
BatchOperator.execute();
}
use of com.alibaba.alink.operator.batch.statistics.CorrelationBatchOp in project Alink by alibaba.
the class Chap16 method c_2.
static void c_2() throws Exception {
CsvSourceBatchOp source = new CsvSourceBatchOp().setFilePath(DATA_DIR + ORIGIN_FILE).setSchemaStr(Utils.generateSchemaString(COL_NAMES, COL_TYPES)).setFieldDelimiter(";").setIgnoreFirstLine(true);
source.lazyPrint(5);
source.link(new CorrelationBatchOp().lazyPrintCorrelation());
source.groupBy(LABEL_COL_NAME, LABEL_COL_NAME + ", COUNT(*) AS cnt").orderBy(LABEL_COL_NAME, 100).lazyPrint(-1);
BatchOperator.execute();
Utils.splitTrainTestIfNotExist(source, DATA_DIR + TRAIN_FILE, DATA_DIR + TEST_FILE, 0.8);
}
Aggregations