title: sklearn.tree.DecisionTreeRegressor: depth of tree is bigger than specified when max_leaf_nodes != None
body: <p>I am currently working on a prediction problem, which i tried to solve with a <code>scikit-learns DecisionTreeRegressor</code> when i came across the following issue:</p>
  
  <blockquote>
    <p>When fitting a tree specifying both parameters <code>max_depth</code> and
    <code>max_leaf_nodes</code>, the <code>depth</code> of the resulting tree is <code>max_depth+1</code>.
    When fitting a tree specifying only <code>max_depth</code>, the resulting tree
    has the <code>correct depth</code>.</p>
  </blockquote>
  
  <p>Could this be a mistake in the <code>DecisionTreeRegressor class</code> or am i missing some common knowledge about regression trees?</p>
  
  <p>I am working on a windows machine, in a python 3.7 jupyter notebook. Sklearn version is 0.20.3.
  Actually i came across this working with <code>RandomForestRegressor</code>, but found the same issue for <code>DecisionTreeRegressor</code>.</p>
  
  <p>I wrote the following simplified example, so you can try yourself. Just uncomment <code>max_leaf_nodes=10</code>.</p>
  
  <p>I also visualized the trees using <code>graphviz</code>, which actually showed trees of different depth.</p>
  
  <pre class="lang-py prettyprint-override"><code>import numpy as np
  from sklearn.tree import DecisionTreeRegressor
  
  X = np.random.rand(10,4)
  y = np.random.rand(10,1)
  
  
  tree = DecisionTreeRegressor(max_depth = 2,
                               #max_leaf_nodes = 10 
                               )
  tree.fit(X,y)
  
  print(tree.tree_.max_depth)
  </code></pre>
  
  <p>Thanks for any comments.</p>