When we plot a XGBOOST tree, we could see the Leafs/Nodes using ,
!pip install --upgrade pip
!pip install graphviz
!sudo apt -y install graphviz
from xgboost import XGBRegressor
from matplotlib import pyplot as plt
from xgboost import plot_tree
xgb =XGBRegressor()
xgb.fit(df,Y)
plt.rcParams["figure.figsize"] = (400, 100)
plot_tree(xgb)
plt.show()
Can we have a Programatic way to select the Data for definition of leaf or node ?
Eg: For the given Tree,
Eg: For the given Tree, we could have the left most node we can have the
Leaf Node Sub Data Frame as
subDf = df[df[6]<1.679][df[4]<761][df[6]<2.651]
Can we Generate this Rule as ( #PSeudo Code ) `
for node is XgbModel:
nodeVariable = node.variavle
nodeMaxValue = node.maxVal
# leftRule = nodeVariable > nodeMaxValue
# Rules.Append(leftRule)
# Rules.Append(getRules(node.Left))
`