<div dir="ltr">Hey Shubham, <div><br></div><div>I am a project reviewer at Udacity. This code seems to be part of one of our projects (<a href="https://github.com/WittmannF/Machine_Learning-Boston_Housing/blob/master/boston_housing.ipynb">P1 - Boston Housing</a>). I think that you have updated the old module <font face="monospace, monospace">sklearn.cross_validation</font> to the module <span style="font-family:monospace,monospace">sklearn.model_detection</span><font face="arial, helvetica, sans-serif">, is t</font>hat correct? If yes, then you should also update the parameters in <font face="monospace, monospace">ShuffleSplit</font> to match with this new version (check the <a href="http://scikit-learn.org/stable/modules/generated/sklearn.model_selection.ShuffleSplit.html">docs</a>). Try to update <font face="monospace, monospace">ShuffleSplit</font> to the following line of code:</div><div><br></div><div><font face="monospace, monospace"> cv_sets = ShuffleSplit(n_splits=10, test_size=0.2, random_state=0)</font></div><div><br></div><div>I hope that helps! Feel free to send me a PM. </div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 7, 2017 at 10:24 AM, Shubham Singh Tomar <span dir="ltr"><<a href="mailto:tomarshubham24@gmail.com" target="_blank">tomarshubham24@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br>I'm trying to use GridSearchCV to tune the parameters for DecisionTreeRegressor. I'm using sklearn 0.18.1</div><div><br></div><div>I'm getting the following error:<br><br></div><div><pre style="box-sizing:border-box;overflow:auto;font-size:14px;padding:0px;margin-top:0px;margin-bottom:0px;line-height:inherit;word-break:break-all;word-wrap:break-word;color:rgb(0,0,0);border:0px;border-radius:0px;white-space:pre-wrap;vertical-align:baseline"><span class="m_-9114157475010249135gmail-ansired" style="box-sizing:border-box;color:darkred">------------------------------<wbr>------------------------------<wbr>---------------</span>
<span class="m_-9114157475010249135gmail-ansired" style="box-sizing:border-box;color:darkred">TypeError</span> Traceback (most recent call last)
<span class="m_-9114157475010249135gmail-ansigreen" style="box-sizing:border-box;color:darkgreen"><ipython-input-36-<wbr>192f7c286a58></span> in <span class="m_-9114157475010249135gmail-ansicyan" style="box-sizing:border-box;color:steelblue"><module><span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue">()</span>
<span class="m_-9114157475010249135gmail-ansigreen" style="box-sizing:border-box;color:darkgreen"> 1</span> <span class="m_-9114157475010249135gmail-ansired" style="box-sizing:border-box;color:darkred"># Fit the training data to the model using grid search</span><span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue"></span><span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue"></span>
<span class="m_-9114157475010249135gmail-ansigreen" style="box-sizing:border-box;color:darkgreen">----> 2<span class="m_-9114157475010249135gmail-ansired" style="box-sizing:border-box;color:darkred"> </span>reg <span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue">=</span> fit_model<span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue">(</span>X_train<span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue">,</span> y_train<span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue">)</span><span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue"></span>
<span class="m_-9114157475010249135gmail-ansigreen" style="box-sizing:border-box"> 3</span> <span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue"></span>
<span class="m_-9114157475010249135gmail-ansigreen" style="box-sizing:border-box"> 4</span> <span class="m_-9114157475010249135gmail-ansired" style="box-sizing:border-box;color:darkred"># Produce the value for 'max_depth'</span><span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue"></span><span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue"></span>
<span class="m_-9114157475010249135gmail-ansigreen" style="box-sizing:border-box"> 5</span> <span class="m_-9114157475010249135gmail-ansigreen" style="box-sizing:border-box">print</span> <span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue">"Parameter 'max_depth' is {} for the optimal model."</span><span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue">.</span>format<span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue">(</span>reg<span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue">.</span>get_params<span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue">(</span><span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue"><wbr>)</span><span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue">[</span><span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue">'max_depth'</span><span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue">]</span><span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue">)</span><span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue"></span>
<span class="m_-9114157475010249135gmail-ansigreen" style="box-sizing:border-box"><ipython-input-35-<wbr>500141c331d9></span> in <span class="m_-9114157475010249135gmail-ansicyan" style="box-sizing:border-box;color:steelblue">fit_model<span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue">(X, y)</span>
<span class="m_-9114157475010249135gmail-ansigreen" style="box-sizing:border-box;color:darkgreen"> 11</span> <span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue"></span>
<span class="m_-9114157475010249135gmail-ansigreen" style="box-sizing:border-box;color:darkgreen"> 12</span> <span class="m_-9114157475010249135gmail-ansired" style="box-sizing:border-box;color:darkred"># Create cross-validation sets from the training data</span><span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue"></span><span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue"></span>
<span class="m_-9114157475010249135gmail-ansigreen" style="box-sizing:border-box;color:darkgreen">---> 13<span class="m_-9114157475010249135gmail-ansired" style="box-sizing:border-box;color:darkred"> </span>cv_sets <span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue">=</span> ShuffleSplit<span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue">(</span>X<span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue">.</span>shape<span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue">[</span><span class="m_-9114157475010249135gmail-ansicyan" style="box-sizing:border-box;color:steelblue">0</span><span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue">]</span><span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue">,</span> n_splits <span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue">=</span> <span class="m_-9114157475010249135gmail-ansicyan" style="box-sizing:border-box;color:steelblue">10</span><span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue">,</span> test_size <span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue">=</span> <span class="m_-9114157475010249135gmail-ansicyan" style="box-sizing:border-box;color:steelblue">0.20</span><span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue">,</span> random_state <span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue">=</span> <span class="m_-9114157475010249135gmail-ansicyan" style="box-sizing:border-box;color:steelblue">0</span><span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue">)</span><span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue"></span>
<span class="m_-9114157475010249135gmail-ansigreen" style="box-sizing:border-box"> 14</span> <span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue"></span>
<span class="m_-9114157475010249135gmail-ansigreen" style="box-sizing:border-box"> 15</span> <span class="m_-9114157475010249135gmail-ansired" style="box-sizing:border-box;color:darkred"># TODO: Create a decision tree regressor object</span><span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue"></span><span class="m_-9114157475010249135gmail-ansiblue" style="box-sizing:border-box;color:darkblue"></span>
<span class="m_-9114157475010249135gmail-ansired" style="box-sizing:border-box;color:darkred">TypeError</span>: __init__() got multiple values for keyword argument 'n_splits'
</span></span></span></span></pre><span class="HOEnZb"><font color="#888888"><div><span class="m_-9114157475010249135gmail-ansicyan" style="box-sizing:border-box;color:steelblue"><span class="m_-9114157475010249135gmail-ansigreen" style="box-sizing:border-box;color:darkgreen"><span class="m_-9114157475010249135gmail-ansicyan" style="box-sizing:border-box;color:steelblue"><span class="m_-9114157475010249135gmail-ansigreen" style="box-sizing:border-box;color:darkgreen"><br></span></span></span></span></div><div><br></div><div><br></div>-- <br><div class="m_-9114157475010249135gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><b>Thanks,</b><div><b>Shubham Singh Tomar</b></div><div><b><a href="http://Autodidact24.github.io" target="_blank">Autodidact24.github.io</a></b></div></div></div></div></div></div>
</font></span></div></div>
<br>______________________________<wbr>_________________<br>
scikit-learn mailing list<br>
<a href="mailto:scikit-learn@python.org">scikit-learn@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/scikit-learn" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/scikit-learn</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div dir="ltr"><div><br><font face="monospace, monospace">Fernando Marcos Wittmann</font></div><div><br></div></div></div></div>
</div></div>