全部產品
Search
文件中心

Platform For AI:GBDT迴歸

更新時間:Apr 03, 2025

梯度漸進迴歸樹GBDT(Gradient Boosting Decision Tree)是一種先進的機器學習演算法,採用迭代方式構建決策樹集合來進行迴歸分析。該演算法通過逐步最佳化損失函數,能夠有效處理線性和非線性迴歸問題,提供高精度的預測結果。

配置組件

方式一:可視化方式

在Designer工作流程頁面添加GBDT迴歸組件,並在介面右側配置相關參數:

參數類型

參數

描述

欄位設定

輸入列

輸入資料來源中,參與訓練的特徵列。支援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~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

所有數值列

輸入表中,用於訓練的特徵列名。支援DOUBLE及BIGINT類型。

labelColName

輸入表中的標籤列名,支援DOUBLE及BIGINT類型。

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

    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}