Question: Instantiate a new DecisionTreeClassifier object, and use the best _ params _ attribute of the grid _ search _ cv object to specify the best

Instantiate a new DecisionTreeClassifier object, and use the best_params_ attribute of the grid_search_cv object to specify the best max_depth, max_leaf_nodes and min_samples_split values calculated from the grid search along with a random_state of 42. Retrain the "optimal" (for the few parameters that we swept) decision tree.
Next, use the tree.export_text() method to visualize the "optimal" decision tree. This function takes a trained classifier as its first parameter, and a set of feature names as its second parameter (the feature names are included in the iris dictionary returned from the load_iris() function). The result is a text based visualization of the decision tree. Note that this method returns a string, so you'll want to print() the result to get it to look right.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!