Q2 - Wrap-up quiz 5

For this quiz, i have a question, one way to see the optimal depth is ranging could be using the method of question 3 in wrap-up quiz 3?

The code is here:

results = (
    pd.DataFrame(grid_search.cv_results_)
    .sort_values(by="mean_test_score", ascending=False)
)

results = results[
    [depth for depth in results.columns if depth.startswith("param_")]
    + ["mean_test_score", "std_test_score"]
]

#results['mean_+_std_score']= results['mean_test_score'] + results['std_test_score']
results.index = range(1,len(results)+1)
results

Thanks for the help

The issue here is that you are not doing the outer cross-validation using cross_validate. Once that you do the outer cross-validation, you will get several best max_depth and you can check their range.

In your example, you only look at the inner cross-validation and get a single max_depth.