max_depth parameter networking
YueruLi opened this issue · 2 comments
YueruLi commented
The max_depth parameter seems to not be working. The fit function fits a tree with maximal possible depth regardless of setting.
Davidmenamm commented
I confirm the issue, it happens to me also.
serengil commented
You are right! max depth is just used for the number of trees in gbm. I fixed it with the following control. You can clone the latest code. It will be published on pypi soon.
elif algorithm == 'Regression' and (subdataset.shape[0] < 5 or root >= max_depth): #pruning condition
#elif algorithm == 'Regression' and subdataset['Decision'].std(ddof=0)/global_stdev < 0.4: #pruning condition
final_decision = subdataset['Decision'].mean() #get average
terminateBuilding = True
elif algorithm in ['ID3', 'C4.5', 'CART', 'CHAID'] and root >= max_depth:
final_decision = subdataset['Decision'].value_counts().idxmax() #get the most frequent one
terminateBuilding = True