Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Samsung Galaxy S23 Ultra Comprehensive User Manual

Authors: Leo Scott

1st Edition

B0BVPBJK5Q, 979-8377286455

More Books

Students also viewed these Databases questions

Question

Describe three other types of visual aids.

Answered: 1 week ago