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 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
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
