Search in sources :

Example 1 with GbdtRegressor

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

the class Chap16 method c_5.

static void c_5() throws Exception {
    AkSourceBatchOp train_data = new AkSourceBatchOp().setFilePath(DATA_DIR + TRAIN_FILE);
    AkSourceBatchOp test_data = new AkSourceBatchOp().setFilePath(DATA_DIR + TEST_FILE);
    for (int numTrees : new int[] { 16, 32, 64, 128, 256, 512 }) {
        new GbdtRegressor().setLearningRate(0.05).setMaxLeaves(256).setFeatureSubsamplingRatio(0.3).setMinSamplesPerLeaf(2).setMaxDepth(100).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("GbdtRegressor - " + numTrees));
        BatchOperator.execute();
    }
}
Also used : AkSourceBatchOp(com.alibaba.alink.operator.batch.source.AkSourceBatchOp) EvalRegressionBatchOp(com.alibaba.alink.operator.batch.evaluation.EvalRegressionBatchOp) GbdtRegressor(com.alibaba.alink.pipeline.regression.GbdtRegressor)

Example 2 with GbdtRegressor

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

the class GridSearchTVSplitTest method findBestReg.

@Test
public void findBestReg() {
    GbdtRegressor gbdtClassifier = new GbdtRegressor().setFeatureCols(colNames[0], colNames[1]).setLabelCol(colNames[2]).setMinSamplesPerLeaf(1).setPredictionCol("pred");
    ParamGrid grid = new ParamGrid().addGrid(gbdtClassifier, GbdtClassifier.NUM_TREES, new Integer[] { 1, 2 });
    GridSearchTVSplit gridSearchTVSplit = new GridSearchTVSplit().setEstimator(gbdtClassifier).setParamGrid(grid).setTuningEvaluator(new RegressionTuningEvaluator().setTuningRegressionMetric(TuningRegressionMetric.RMSE).setLabelCol(colNames[2]).setPredictionCol("pred"));
    GridSearchTVSplitModel model = gridSearchTVSplit.fit(memSourceBatchOp);
    Assert.assertEquals(testArray.length, model.transform(memSourceBatchOp).collect().size());
}
Also used : GbdtRegressor(com.alibaba.alink.pipeline.regression.GbdtRegressor) Test(org.junit.Test)

Example 3 with GbdtRegressor

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

the class GridSearchCVTest method findBestReg.

@Test
public void findBestReg() {
    GbdtRegressor gbdtClassifier = new GbdtRegressor().setFeatureCols(colNames[0], colNames[1]).setLabelCol(colNames[2]).setMinSamplesPerLeaf(1).setPredictionCol("pred");
    ParamGrid grid = new ParamGrid().addGrid(gbdtClassifier, GbdtClassifier.NUM_TREES, new Integer[] { 1, 2 });
    GridSearchCV gridSearchCV = new GridSearchCV().setEstimator(gbdtClassifier).setParamGrid(grid).setNumFolds(2).setTuningEvaluator(new RegressionTuningEvaluator().setTuningRegressionMetric(TuningRegressionMetric.RMSE).setLabelCol(colNames[2]).setPredictionCol("pred"));
    GridSearchCVModel model = gridSearchCV.fit(memSourceBatchOp);
    Assert.assertEquals(testArray.length, model.transform(memSourceBatchOp).collect().size());
}
Also used : GbdtRegressor(com.alibaba.alink.pipeline.regression.GbdtRegressor) Test(org.junit.Test)

Aggregations

GbdtRegressor (com.alibaba.alink.pipeline.regression.GbdtRegressor)3 Test (org.junit.Test)2 EvalRegressionBatchOp (com.alibaba.alink.operator.batch.evaluation.EvalRegressionBatchOp)1 AkSourceBatchOp (com.alibaba.alink.operator.batch.source.AkSourceBatchOp)1