title: Decision tree Regressor model get max_depth value of the model with highest accuracy
body: <p>Build a Decision tree Regressor model from X_train set and Y_train labels, with default parameters. Name the model as dt_reg.</p>
  <p>Evaluate the model accuracy on the training data set and print its score.</p>
  <p>Evaluate the model accuracy on the testing data set and print its score.</p>
  <p>Predict the housing price for the first two samples of the X_test set and print them.(Hint : Use predict() function)</p>
  <p>Fit multiple Decision tree regressors on X_train data and Y_train labels with max_depth parameter value changing from 2 to 5.</p>
  <p>Evaluate each model's accuracy on the testing data set.</p>
  <p><strong>Hint: Make use of for loop</strong></p>
  <blockquote>
  <p>Print the max_depth value of the model with the highest accuracy.</p>
  </blockquote>
  <pre><code>import sklearn.datasets as datasets
  from sklearn.model_selection import train_test_split 
  from sklearn.tree import DecisionTreeRegressor
  import numpy as np
  np.random.seed(100) 
  boston = datasets.load_boston()
  X_train, X_test, Y_train, Y_test = train_test_split(boston.data, boston.target, random_state=30)
  print(X_train.shape)
  print(X_test.shape)
  
  dt_reg = DecisionTreeRegressor()   
  dt_reg = dt_reg.fit(X_train, Y_train) 
  print(dt_reg.score(X_train,Y_train))
  print(dt_reg.score(X_test,Y_test))
  y_pred=dt_reg.predict(X_test[:2])
  print(y_pred)
  </code></pre>
  <p>I want to get <strong>Print the max_depth value of the model with the highest accuracy</strong>. But fresco plays not submitted Let me know what is error.</p>
  <pre><code>max_reg = None
  max_score = 0  
  t=()
  for m in range(2, 6) :
      rf_reg = DecisionTreeRegressor(max_depth=m)
      rf_reg = rf_reg.fit(X_train, Y_train) 
      rf_reg_score = rf_reg.score(X_test,Y_test)
      print (m, rf_reg_score ,max_score) 
      if rf_reg_score &gt; max_score :
          max_score = rf_reg_score
          max_reg = rf_reg
          t = (m,max_score) 
  print (t)
  </code></pre>