Search in sources :

Example 1 with RandomForestRegressor

use of com.alibaba.alink.pipeline.regression.RandomForestRegressor in project Alink by alibaba.

the class Chap16 method c_4.

static void c_4() throws Exception {
    AkSourceBatchOp train_data = new AkSourceBatchOp().setFilePath(DATA_DIR + TRAIN_FILE);
    AkSourceBatchOp test_data = new AkSourceBatchOp().setFilePath(DATA_DIR + TEST_FILE);
    new DecisionTreeRegressor().setFeatureCols(FEATURE_COL_NAMES).setLabelCol(LABEL_COL_NAME).setPredictionCol(PREDICTION_COL_NAME).fit(train_data).transform(test_data).link(new EvalRegressionBatchOp().setLabelCol(LABEL_COL_NAME).setPredictionCol(PREDICTION_COL_NAME).lazyPrintMetrics("DecisionTreeRegressor"));
    BatchOperator.execute();
    for (int numTrees : new int[] { 2, 4, 8, 16, 32, 64, 128 }) {
        new RandomForestRegressor().setNumTrees(numTrees).setFeatureCols(FEATURE_COL_NAMES).setLabelCol(LABEL_COL_NAME).setPredictionCol(PREDICTION_COL_NAME).fit(train_data).transform(test_data).link(new EvalRegressionBatchOp().setLabelCol(LABEL_COL_NAME).setPredictionCol(PREDICTION_COL_NAME).lazyPrintMetrics("RandomForestRegressor - " + numTrees));
        BatchOperator.execute();
    }
}
Also used : AkSourceBatchOp(com.alibaba.alink.operator.batch.source.AkSourceBatchOp) DecisionTreeRegressor(com.alibaba.alink.pipeline.regression.DecisionTreeRegressor) EvalRegressionBatchOp(com.alibaba.alink.operator.batch.evaluation.EvalRegressionBatchOp) RandomForestRegressor(com.alibaba.alink.pipeline.regression.RandomForestRegressor)

Aggregations

EvalRegressionBatchOp (com.alibaba.alink.operator.batch.evaluation.EvalRegressionBatchOp)1 AkSourceBatchOp (com.alibaba.alink.operator.batch.source.AkSourceBatchOp)1 DecisionTreeRegressor (com.alibaba.alink.pipeline.regression.DecisionTreeRegressor)1 RandomForestRegressor (com.alibaba.alink.pipeline.regression.RandomForestRegressor)1