Answered step by step
Verified Expert Solution
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 bestparams attribute of the gridsearchcv object to specify the best maxdepth, maxleafnodes and minsamplessplit values calculated from the grid search along with a randomstate of Retrain the "optimal" for the few parameters that we swept decision tree.
Next, use the tree.exporttext 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 loadiris 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started