Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在python的lightgbm中计算分割增益_Python_Scikit Learn_Lightgbm - Fatal编程技术网

如何在python的lightgbm中计算分割增益

如何在python的lightgbm中计算分割增益,python,scikit-learn,lightgbm,Python,Scikit Learn,Lightgbm,我想知道lightgbm如何计算分割增益。 我看到split\u gain=sum\u grad/sum\u hessat 但是,我看到那不是真的。 资料来源如下 import numpy as np import pandas as pd import matplotlib.pyplot as plt from lightgbm import LGBMRegressor from lightgbm.plotting import * d = pd.DataFrame({"x1&qu

我想知道lightgbm如何计算分割增益。 我看到
split\u gain=sum\u grad/sum\u hess
at

但是,我看到那不是真的。 资料来源如下

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from lightgbm import LGBMRegressor
from lightgbm.plotting import *

d = pd.DataFrame({"x1":[-2, -1, 0, 1, 2],"y":[4, 1, 0, 1, 4]})
输出是

[-8. -2. -0. -2. -8.] [2. 2. 2. 2. 2.] -20.0 10.0
[-4.66666667 13.33333333 33.33333333 30.         -3.        ] [ 2. 20. 20. 20.  2.] 68.99999999999999 64.0
[-5.45454544  5.4545456   4.60317521  1.26984188 -5.87301581] [ 2. 20. 20. 20.  2.] 1.4305114603985203e-06 64.0
[-5.67374426  3.26255743  2.41118704  5.45454549 -5.45454545] [ 2. 20. 20. 20.  2.] 2.3841856311435095e-07 64.0
[-5.45454547  5.45454533  1.26300278  4.30636123 -5.56936388] [ 2. 20. 20. 20.  2.] -1.509903313490213e-14 64.0

我尝试过其他条件,但我不知道lgbm如何计算分割增益

请告诉我

l2 = LGBMRegressor(min_child_samples=1, min_child_weight=0, n_estimators=5, max_depth=1, learning_rate=1, min_gain_to_split=0, objective=custom_asymmetric_train)

l2.fit(d[["x1"]], d[["y"]].values.ravel())
create_tree_digraph(booster=l2, show_info=['split_gain', 'internal_value', 'internal_count', 'leaf_count'], tree_index=0)
[-8. -2. -0. -2. -8.] [2. 2. 2. 2. 2.] -20.0 10.0
[-4.66666667 13.33333333 33.33333333 30.         -3.        ] [ 2. 20. 20. 20.  2.] 68.99999999999999 64.0
[-5.45454544  5.4545456   4.60317521  1.26984188 -5.87301581] [ 2. 20. 20. 20.  2.] 1.4305114603985203e-06 64.0
[-5.67374426  3.26255743  2.41118704  5.45454549 -5.45454545] [ 2. 20. 20. 20.  2.] 2.3841856311435095e-07 64.0
[-5.45454547  5.45454533  1.26300278  4.30636123 -5.56936388] [ 2. 20. 20. 20.  2.] -1.509903313490213e-14 64.0