GBDT回归

更新时间:2025-04-02 05:57:06

梯度渐进回归树GBDT(Gradient Boosting Decision Tree)是一种先进的机器学习算法,采用迭代方式构建决策树集合来进行回归分析。该算法通过逐步优化损失函数,能够有效处理线性和非线性回归问题,提供高精度的预测结果。

配置组件

方式一:可视化方式

Designer工作流页面添加GBDT回归组件,并在界面右侧配置相关参数:

参数类型

参数

描述

参数类型

参数

描述

字段设置

输入列

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

说明

特征列数量不能超过800。

标签列

支持DOUBLEBIGINT类型。

分组列

支持DOUBLEBIGINT类型,默认将全表作为一组。

参数设置

损失函数类型

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

gbrank loss中的Tau参数

取值范围为[0,1]

gbrankregression loss中的指数底数

取值范围为[1,10]

metric类型

支持NDCGDCG类型。

树数量

取值范围为1~10000。

学习速率

取值范围为(0,1)

最大叶子数

取值范围为1~1000。

一棵树的最大深度

取值范围为1~11。

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

取值范围为1~1000。

样本采样比例

取值范围为(0,1)

训练中采集的特征比例

取值范围为(0,1)

测试样本数比例

取值范围为[0,1)

随机数产生器种子

取值范围为[0,10]

是否使用newton方法来学习

使用Newton方法的开关。

一个特征分裂的最大数量

取值范围为1~1000。

执行调优

计算核心数

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

每个核内存

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

方式二:PAI命令方式

使用PAI命令配置GBDT回归组件参数。您可以使用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

所有数值列

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

labelColName

输入表中的标签列名,支持DOUBLEBIGINT类型。

inputTablePartitions

所有分区

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

  • Partition_name=value

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

说明

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

modelName

输出的模型名称。

outputImportanceTableName

输出特征重要性的表名。

groupIDColName

全表

数据分组列。

lossType

0

损失函数包括以下类型:

  • 0:GBRANK

  • 1:LAMBDAMART_DCG

  • 2:LAMBDAMART_NDCG

  • 3:LEAST_SQUARE

metricType

0

包括以下类型:

  • 0:NDCG(Normalized Discounted Cumulative Gain)

  • 1:DCG(Discounted Cumulative Gain)

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

treeCount

500

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

shrinkage

0.05

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

maxLeafCount

32

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

maxDepth

10

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

minLeafSampleCount

500

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

sampleRatio

0.6

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

featureRatio

0.6

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

tau

0.6

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

p

1

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

randSeed

0

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

newtonStep

1

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

featureSplitValueMaxSize

500

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

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
        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
        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
        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
        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
        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
    ) a;

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

    f0

    f1

    f2

    f3

    label

    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

    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)
  • 配置组件
  • 方式一:可视化方式
  • 方式二:PAI命令方式
  • 示例
AI助理

点击开启售前

在线咨询服务

你好,我是AI助理

可以解答问题、推荐解决方案等