You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For me it seems, that there is a bug going on when using max_depth and max_leaf_nodes. Whenever I use max_leaf_nodes for a DecisionTreeRegressor, the given max_depth is ignored (or at least not working as expected). When I remove the max_leaf_nodes, it seems to work.
Is there any reason, max_depth might be ignored when using max_leaf_nodes? I can't see one, but I am quite fresh into machine learning. If there is a reason, it should probably be added to the docs, shouldn't it?
Description
For me it seems, that there is a bug going on when using max_depth and max_leaf_nodes. Whenever I use max_leaf_nodes for a DecisionTreeRegressor, the given max_depth is ignored (or at least not working as expected). When I remove the max_leaf_nodes, it seems to work.
Steps/Code to Reproduce
Expected Results
I expect a tree with a maximum of 3 nodes (the root and two leafs).
Actual Results
DecisionTreeRegressor(criterion='mse', max_depth=1, max_features=None,
max_leaf_nodes=99, min_impurity_decrease=0.0,
min_impurity_split=None, min_samples_leaf=1,
min_samples_split=2, min_weight_fraction_leaf=0.0,
presort=False, random_state=None, splitter='best')
Number of nodes: 5
Exporting the tree via export_graphviz results in this image:

Versions
System:
python: 3.6.7 | packaged by conda-forge | (default, Nov 21 2018, 02:32:25) [GCC 4.8.2 20140120 (Red Hat 4.8.2-15)]
executable: /opt/conda/bin/python
machine: Linux-4.14.79-boot2docker-x86_64-with-debian-buster-sid
BLAS:
macros: HAVE_CBLAS=None
lib_dirs: /opt/conda/lib
cblas_libs: openblas, openblas
Python deps:
pip: 19.0.1
setuptools: 40.6.3
sklearn: 0.20.1
numpy: 1.13.3
scipy: 1.1.0
Cython: 0.28.5
pandas: 0.23.4
The text was updated successfully, but these errors were encountered: