October 2018
Intermediate to advanced
172 pages
4h 6m
English
Just as we visualized the decision tree classifier, we can also visualize the decision tree regressor. Instead of showing you the classes or categories to which the node of a tree belongs, you will now be shown the value of the target variable.
We can visualize the decision tree regressor by using the following code:
#Package requirements from sklearn.tree import DecisionTreeClassifierfrom sklearn.externals.six import StringIO from IPython.display import Image from sklearn.tree import export_graphvizimport pydotplusfrom sklearn import tree#Extracting the feature namesfeature_names = df.drop('amount', axis = 1)#Creating the tree visualizationdata = tree.export_graphviz(dt_reg, out_file=None, feature_names= ...Read now
Unlock full access