菜鸟求助:把Xgboost结果转成SQL语句
各位大神,我有一个下面的问题:通过一个简单的Xgboost模型,用如下语句可以导出模型的树状结果:
bst.dump_model("E:\Python\model.txt")
结果类似如下:
booster[0]:
0:[f2<2.45000005] yes=1,no=2,missing=1
1:leaf=-0.021014493
2:leaf=0.0205882359
booster[1]:
0:[f2<2.3499999] yes=1,no=2,missing=1
1:leaf=-0.0190295223
2:leaf=0.021607263
booster[2]:
0:[f2<2.45000005] yes=1,no=2,missing=1
1:leaf=-0.020597266
2:leaf=0.0209805444
booster[3]:
0:[f3<0.75] yes=1,no=2,missing=1
1:leaf=-0.0203853883
2:leaf=0.0199462976
我想把上面的结果转换成SQL,类似如下:
Case when f2<2.45000005 then -0.021014493 else 0.0205882359 end as a1,
Case when f2<2.3499999 then -0.0190295223 else 0.021607263 end as a2......
请问如何实现? 谢谢!