One of the best aspects of building and implementing a decision tree in order to solve problems is that it can be interpreted quite easily, using a decision tree diagram that explains how the algorithm that you built works. In order to visualize a simple decision tree for the fraud detection dataset, we use the following code:
#Package requirements import pandas as pdfrom sklearn.tree import DecisionTreeClassifierfrom sklearn.externals.six import StringIO from IPython.display import Image from sklearn.tree import export_graphvizimport pydotplusfrom sklearn import tree
We start by importing the required packages. The new packages here are the following:
- StringIO
- Image
- export_graphviz
- pydotplus
- tree
The installations ...