GBDT安装(xgboost LightGBM)

本文介绍了GBDT的安装过程,包括XGBoost的模型和数据格式,以及Python与C++的安装步骤。在Python环境下,通过pip安装gbdt时遇到的GLIBC_2.14版本不匹配问题以及解决方法。此外,文章提到了AdaBoost算法的简要讲解和其优缺点。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1,XGBoost 之model

1.训练集和测试集都是libsvm格式,如下所示:(label idx:val idxN:valN)并且idx从1开始的

1 3:1 10:1 11:1 21:1 30:1 34:1 36:1 40:1 41:1 53:1 58:1 65:1 69:1 77:1 86:1 88:1 92:1 95:1 102:1 105:1 117:1 124:1
0 3:1 10:1 20:1 21:1 23:1 34:1 36:1 39:1 41:1 53:1 56:1 65:1 69:1 77:1 86:1 88:1 92:1 95:1 102:1 106:1 116:1 120:1

2.最终生成的模型如下所示:

booster[0]:
0:[f824<4] yes=1,no=2,missing=2
    1:[f459<4] yes=3,no=4,missing=4
        3:[f718<8] yes=7,no=8,missing=8
            7:[f4<16] yes=15,no=16,missing=16
                15:leaf=0.04
                16:leaf=0.0832258
            8:[f3<74.5] yes=17,no=18,missing=18
                17:[f3<3.5] yes=31,no=32,missing=32
                    31:leaf=0.0392857
                    32:leaf=0.075
                18:[f546<1.5] yes=33,no=34,missing=34
                    33:leaf=-0.0166667
                    34:leaf=0.0454545
        4:[f1892<-9.53674e-07] yes=9,no=10,missing=9
            9:[f5<14.875] yes=19,no=20,missing=19
                19:[f9<27.45] yes=35,no=36,missing=36
                    35:leaf=0.0414993
                    36:leaf=-0
                20:[f9<9.15] yes=37,no=38,missing=38
                    37:leaf=-0.0434783
                    38:leaf=0.0227181
            10:[f8<1.65] yes=21,no=22,missing=21
                21:leaf=0.0798883
                22:[f6<24] yes=41,no=42,missing=42
                    41:leaf=0.06
                    42:leaf=0.008
    2:[f507<-9.53674e-07] yes=5,no=6,missing=5
        5:[f3238<6] yes=11,no=12,missing=12
            11:[f707<-9.53674e-07] yes=23,no=24,missing=23
                23:[f453<4] yes=43,no=44,missing=44
                    43:leaf=0.0668712
                    44:leaf=0.02723
                24:[f343<2] yes=45,no=46,missing=46
                    45:leaf=0.044
                    46:leaf=0.0803738
            12:[f778<4] yes=25,no=26,missing=26
                25:[f718<6] yes=47,no=48,missing=48
                    47:leaf=0.06
                    48:leaf=0.0358086
                26:[f902<4] yes=49,no=50,missing=50
                    49:leaf=0.0586066
                    50:leaf=0.00294413
        6:[f5<5.875] yes=13,no=14,missing=13
            13:[f9<5.25] yes=27,no=28,missing=28
                27:leaf=0.045098
                28:leaf=0.00555556
            14:[f8<5.25] yes=29,no=30,missing=29
                29:[f69<1.5] yes=51,no=52,missing=52
                    51:leaf=0.0565657
                    52:leaf=0.0762115
                30:[f5<37] yes=53,no=54,missing=54
                    53:leaf=0.0211009
                    54:leaf=0.09
booster[1]:
0:[f507<-9.53674e-07] yes=1,no=2,missing=1
    1:[f5577<-9.53674e-07] yes=3,no=4,missing=3
        3:[f2316<4] yes=7,no=8,missing=8
            7:[f1693<4] yes=15,no=16,missing=16
                15:[f8<1.35] yes=23,no=24,missing=23
                    23:leaf=0.0791827
                    24:leaf=0.0481712
                16:[f9<32.85] yes=25,no=26,missing=26
                    25:leaf=0.0391999
                    26:leaf=0.0156137
            8:[f778<4] yes=17,no=18,missing=18
                17:[f2<0.375] yes=27,no=28,missing=28
                    27:leaf=0.0620543
                    28:leaf=0.0371438
                18:[f819<4] yes=29,no=30,missing=30
                    29:leaf=0.0330582
                    30:leaf=0.00373361
        4:[f9<3.15] yes=9,no=10,missing=10
            9:leaf=-0.00125297
            10:[f611<-9.53674e-07] yes=19,no=20,missing=19
                19:[f9<26.25] yes=31,no=32,missing=31
                    31:leaf=0.0723316
                    32:leaf=0.0504592
                20:[f9<18.75] yes=33,no=34,missing=34
                    33:leaf=0.0596224
                    34:leaf=0.0112981
    2:[f2<14.35] yes=5,no=6,missing=5
………………
booster[2]: ……
booster[3]:……

相关解释:”numRound: 4, maxDepth: 3”表示生成树的个数为4,树的最大深度为3;booster[n]表示第n棵树;以下保存树的结构,0号节点为根节点,每个节点有两个子节点,节点序号按层序技术,即1号和2号节点为根节点0号节点的子节点,相同层的节点有相同缩进,且比父节点多一级缩进。
  在节点行,首先声明节点序号,中括号里写明该节点采用第几个特征(如f824即为训练数据的第824个特征),同时表明特征值划分条件,“[f824<2] yes=1,no=2,missing=2”:表示f824号特征大于2时该样本划分到1号叶子节
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值