Understanding deep learning using visual examples
Deep learning is one of the most powerful AI techniques, however, it can be difficult to understand. In this blog, I will attempt to explain deep learning using visuals and examples.
Deep learning architecture is inspired by how our brain works. It is a connection of neurons. Deep learning models can have many parameters. The number of parameters is based on the number of layers and neurons, which can exponentially grow for sophisticated architecture.
In this blog, I will take a business use case of financial fraud detection. One of the biggest challenges in fraud detection is the problem of class imbalance, which means that the data used to train machine learning models has very few cases of fraud.
It is like training a machine learning model to find a needle in a haystack. Fraud detection is a special problem that justifies having a sophisticated approach such as deep learning architecture.
In the example, I will take data from the banking transaction system. The data looks as shown here. The data has the type of financial transaction, amount, as well as origin and destination old balance, and new balance. There is also a flag that indicates if the transaction was fraudulent or not.
The citation for the dataset is available at end of the blog.
The data is split into training and test data. The deep learning model is developed on the training set and then it is validated on the test data. Then this model can be used to predict fraud on unseen data.
The deep learning model for fraud prediction is shown here. The input neurons correspond to the transaction data. Each neuron corresponds to a column in the input data such as the type of transaction, amount, and balance information at the origin and destination.
There is one intermediate layer and then the final layer which has two neurons, one which predicts non-fraud and the other which predicts no-fraud.
The lines are signals passed between the different layers. A green line indicates a positive signal and a red line indicate a negative signal
We see that neuron 1_0 is passing a positive signal to neuron Fraud.
This means that it has deep-learned what a fraudulent transaction looks like! This is exciting !
Let us peek inside neuron 1_0!
The radar chart is a representation of what the neuron has learned about the data. A blue line indicates a high value, and a red line indicates a low value. The radar chart indicates a high, but almost similar old and new balance at the origin. However, there is a very big difference between the old and new balance at the destination.
Such a situation is an indication of fraud. This situation can be visually shown below.
Shown here is the accuracy of the deep learning model using a confusion matrix.
In total, there are about 95000 transactions, out of which there are 62 fraudulent transactions, which is extremely less than the total transaction. However, the deep-learning model is doing good as it is able to identify 52 correctly as fraud, which is also called true positive (tp)
There is 1 false positive (fp), meaning, it is not a fraud, but the model incorrectly flagged it as fraud. So the precision, which is tp / (tp +fp), equals 98%.
Also, there are 10 false negatives (fn), which means that they are fraudulent transactions, but our model is not able to predict them. So the measure recall which is tp / (tp +fn) which is 83%
Deep learning architecture is very powerful as it helps solve complex problems such as fraud detection. A visual way to analyze deep learning architecture is useful in understanding the architecture as well as how it solves the problem
Datasource citation for synthetic financial datasets for fraud detection
The synthetic financial datasets for fraud detection is data are available here: https://www.kaggle.com/competitions/spaceship-titanic/overview
As specified in the License section, it has a license CC BY-SA 4.0.
- Share — copy and redistribute the material in any medium or format
- Adapt — remix, transform, and build upon the material for any purpose, even commercially.
Please join Medium with my referral link.
Please subscribe to stay informed whenever I release a new story.
You can visit my website to make analytics with zero coding. https://experiencedatascience.com
On the website, you can also participate in upcoming AI workshops for an interesting and innovative data science and AI experience.
Here is a link to my YouTube channel
Deep Learning Visually Explained Republished from Source https://towardsdatascience.com/deep-learning-visually-explained-a9fff874d280?source=rss—-7f60cf5620c9—4 via https://towardsdatascience.com/feed