文档

GBDT回归

更新时间:

梯度渐进回归树GBDT(Gradient Boosting Decision Tree)是一种迭代决策树算法,适用于线性及非线性回归场景。

组件配置

您可以使用以下任意一种方式,配置GBDT回归组件参数。

方式一:可视化方式

Designer工作流页面配置组件参数。

页签

参数

描述

字段设置

输入列

输入数据源中,参与训练的特征列。支持DOUBLE及BIGINT类型。

说明

特征列数量不能超过800。

标签列

支持DOUBLE及BIGINT类型。

分组列

支持DOUBLE及BIGINT类型,默认将全表作为一组。

参数设置

损失函数类型

支持gbrank losslambdamart dcg losslambdamart ndcg lossregression loss类型。

gbrank loss中的Tau参数

取值范围为[0,1]

gbrank与regression loss中的指数底数

取值范围为[1,10]

metric类型

支持NDCGDCG类型。

树数量

取值范围为1~10000。

学习速率

取值范围为(0,1)

最大叶子数

取值范围为1~1000。

一棵树的最大深度

取值范围为1~100。

叶子节点容纳的最少样本数

取值范围为1~1000。

样本采样比例

取值范围为(0,1)

训练中采集的特征比例

取值范围为(0,1)

测试样本数比例

取值范围为[0,1)

随机数产生器种子

取值范围为[0,10]

是否使用newton方法来学习

使用Newton方法的开关。

一个特征分裂的最大数量

取值范围为1~1000。

执行调优

计算核心数

系统根据输入数据量,自动分配训练的实例数量。

每个核内存

系统根据输入数据量,自动分配内存。单位为MB。

方式二:PAI命令方式

使用PAI命令方式,配置该组件参数。您可以使用SQL脚本组件进行PAI命令调用,详情请参见SQL脚本

PAI -name gbdt
    -project algo_public
    -DfeatureSplitValueMaxSize="500"
    -DlossType="0"
    -DrandSeed="0"
    -DnewtonStep="0"
    -Dshrinkage="0.05"
    -DmaxLeafCount="32"
    -DlabelColName="campaign"
    -DinputTableName="bank_data_partition"
    -DminLeafSampleCount="500"
    -DsampleRatio="0.6"
    -DgroupIDColName="age"
    -DmaxDepth="11"
    -DmodelName="xlab_m_GBDT_83602"
    -DmetricType="2"
    -DfeatureRatio="0.6"
    -DinputTablePartitions="pt=20150501"
    -Dtau="0.6"
    -Dp="1"
    -DtestRatio="0.0"
    -DfeatureColNames="previous,cons_conf_idx,euribor3m"
    -DtreeCount="500"

参数

是否必选

描述

默认值

inputTableName

输入表的名称。

featureColNames

输入表中,用于训练的特征列名。支持DOUBLE及BIGINT类型。

所有数值列

labelColName

输入表中的标签列名,支持DOUBLE及BIGINT类型。

inputTablePartitions

输入表中,参与训练的分区。支持的格式包括:

  • Partition_name=value

  • name1=value1/name2=value2:多级分区

说明

如果指定多个分区,则使用英文逗号(,)分隔。

所有分区

modelName

输出的模型名称。

outputImportanceTableName

输出特征重要性的表名。

groupIDColName

数据分组列。

全表

lossType

损失函数包括以下类型:

  • 0:GBRANK

  • 1:LAMBDAMART_DCG

  • 2:LAMBDAMART_NDCG

  • 3:LEAST_SQUARE

0

metricType

包括以下类型:

  • 0:NDCG(Normalized Discounted Cumulative Gain)

  • 1:DCG(Discounted Cumulative Gain)

  • 2:AUC,仅适用于label取值为0/1的场景(弃用)

0

treeCount

树数量,取值范围为1~10000。

500

shrinkage

学习速率,取值范围为(0,1)

0.05

maxLeafCount

最大叶子数,取值范围为1~1000。

32

maxDepth

树的最大深度,取值范围为1~100。

10

minLeafSampleCount

叶子节点容纳的最少样本数,取值范围为1~1000。

500

sampleRatio

训练采集的样本比例,取值范围为(0,1)

0.6

featureRatio

训练采集的特征比例,取值范围为(0,1)

0.6

tau

GBRank Loss中的Tau参数,取值范围为[0,1]

0.6

p

GBRank Loss中的p参数,取值范围为[1,10]

1

randSeed

随机数种子,取值范围为[0,10]

0

newtonStep

使用Newton迭代法的开关,取值范围为{0,1}

1

featureSplitValueMaxSize

特征分裂的最大数量,取值范围为1~1000。

500

lifecycle

输出表的生命周期。

示例

  1. 使用SQL语句,生成测试数据。

    drop table if exists gbdt_ls_test_input;
    create table gbdt_ls_test_input
    as
    select
        *
    from
    (
        select
            cast(1 as double) as f0,
            cast(0 as double) as f1,
            cast(0 as double) as f2,
            cast(0 as double) as f3,
            cast(0 as bigint) as label
        from dual
        union all
            select
                cast(0 as double) as f0,
                cast(1 as double) as f1,
                cast(0 as double) as f2,
                cast(0 as double) as f3,
                cast(0 as bigint) as label
        from dual
        union all
            select
                cast(0 as double) as f0,
                cast(0 as double) as f1,
                cast(1 as double) as f2,
                cast(0 as double) as f3,
                cast(1 as bigint) as label
        from dual
        union all
            select
                cast(0 as double) as f0,
                cast(0 as double) as f1,
                cast(0 as double) as f2,
                cast(1 as double) as f3,
                cast(1 as bigint) as label
        from dual
        union all
            select
                cast(1 as double) as f0,
                cast(0 as double) as f1,
                cast(0 as double) as f2,
                cast(0 as double) as f3,
                cast(0 as bigint) as label
        from dual
        union all
            select
                cast(0 as double) as f0,
                cast(1 as double) as f1,
                cast(0 as double) as f2,
                cast(0 as double) as f3,
                cast(0 as bigint) as label
        from dual
    ) a;

    生成的测试数据表gbdt_ls_test_input如下。

    f0

    f1

    f2

    f3

    label

    1.0

    0.0

    0.0

    0.0

    0

    0.0

    0.0

    1.0

    0.0

    1

    0.0

    0.0

    0.0

    1.0

    1

    0.0

    1.0

    0.0

    0.0

    0

    1.0

    0.0

    0.0

    0.0

    0

    0.0

    1.0

    0.0

    0.0

    0

  2. 使用PAI命令,提交GBDT回归组件的训练参数。

    drop offlinemodel if exists gbdt_ls_test_model;
    PAI -name gbdt
        -project algo_public
        -DfeatureSplitValueMaxSize="500"
        -DlossType="3"
        -DrandSeed="0"
        -DnewtonStep="1"
        -Dshrinkage="0.5"
        -DmaxLeafCount="32"
        -DlabelColName="label"
        -DinputTableName="gbdt_ls_test_input"
        -DminLeafSampleCount="1"
        -DsampleRatio="1"
        -DmaxDepth="10"
        -DmetricType="0"
        -DmodelName="gbdt_ls_test_model"
        -DfeatureRatio="1"
        -Dp="1"
        -Dtau="0.6"
        -DtestRatio="0"
        -DfeatureColNames="f0,f1,f2,f3"
        -DtreeCount="10"
  3. 使用PAI命令,提交预测组件参数。

    drop table if exists gbdt_ls_test_prediction_result;
    PAI -name prediction
        -project algo_public
        -DdetailColName="prediction_detail"
        -DmodelName="gbdt_ls_test_model"
        -DitemDelimiter=","
        -DresultColName="prediction_result"
        -Dlifecycle="28"
        -DoutputTableName="gbdt_ls_test_prediction_result"
        -DscoreColName="prediction_score"
        -DkvDelimiter=":"
        -DinputTableName="gbdt_ls_test_input"
        -DenableSparse="false"
        -DappendColNames="label"
  4. 查看预测结果表gbdt_ls_test_prediction_result

    label

    prediction_result

    prediction_score

    prediction_detail

    0

    NULL

    0.0

    {“label”: 0}

    0

    NULL

    0.0

    {“label”: 0}

    1

    NULL

    0.9990234375

    {“label”: 0.9990234375}

    1

    NULL

    0.9990234375

    {“label”: 0.9990234375}

    0

    NULL

    0.0

    {“label”: 0}

    0

    NULL

    0.0

    {“label”: 0}

  • 本页导读 (1)
文档反馈