October 2018
Intermediate to advanced
172 pages
4h 6m
English
Now that we have the labeled dataset, we can create a decision tree, in order to convert the unsupervised machine learning problem into a supervised machine learning one.
In order to do this, we start with all of the necessary package imports, as shown in the following code:
from sklearn.tree import DecisionTreeClassifierfrom sklearn.externals.six import StringIOfrom IPython.display import Imagefrom sklearn.tree import export_graphvizimport pydotplusfrom sklearn import tree
Next, we rename the target column to a name that is appropriate (when we merged the target labels created by the k-means algorithm, it produced 0 as the default name). We can do this by using the following code:
#Renaming the target df['fraud'] ...
Read now
Unlock full access