Let's wrap up this Deep Learning by taking a a quick look at the effectiveness of Neural Nets!
We'll use the Bank Authentication Data Set from the UCI repository.
The data consists of 5 columns:
Where class indicates whether or not a Bank Note was authentic.
This sort of task is perfectly suited for Neural Networks and Deep Learning! Just follow the instructions below to get started!
In [1]:
In [3]:
Check the head of the Data
In [61]:
Out[61]:
In [67]:
Create a Countplot of the Classes (Authentic 1 vs Fake 0)
In [68]:
Out[68]:
Create a PairPlot of the Data with Seaborn, set Hue to Class
In [69]:
Out[69]:
In [71]:
Create a StandardScaler() object called scaler.
In [72]:
Fit scaler to the features.
In [73]:
Out[73]:
Use the .transform() method to transform the features to a scaled version.
In [74]:
Convert the scaled features to a dataframe and check the head of this dataframe to make sure the scaling worked.
In [77]:
Out[77]:
In [79]:
In [80]:
Use the .as_matrix() method on X and Y and reset them equal to this result. We need to do this in order for TensorFlow to accept the data in Numpy array form instead of a pandas series.
In [81]:
Use SciKit Learn to create training and testing sets of the data as we've done in previous lectures:
In [45]:
In [46]:
In [82]:
Create an object called classifier which is a DNNClassifier from learn. Set it to have 2 classes and a [10,20,10] hidden unit layer structure:
In [83]:
Now fit classifier to the training data. Use steps=200 with a batch_size of 20. You can play around with these values if you want!
Note: Ignore any warnings you get, they won't effect your output
In [94]:
Out[94]:
In [95]:
Now create a classification report and a Confusion Matrix. Does anything stand out to you?
In [96]:
In [97]:
In [98]:
In [99]:
In [100]:
In [101]:
Out[101]:
In [102]:
In [103]:
In [104]:
It should have also done very well, but not quite as good as the DNN model. Hopefully you have seen the power of DNN!