What is Fraud Dectection?
In simple Data Science language , its somewhat similar to detecting the outliers in a dataset.
Here, I will be solving a fraud detection problem using an unsupervised learning technique called as Self Organizing Maps(SOMs).
A self-organizing map (SOM) is a type of artificial neural network (ANN) that is trained using unsupervised learning to produce a low-dimensional (typically two-dimensional), discretized representation of the input space of the training samples, called a map. In a nutshell , it will reduce multi-dimentional data into a clustered 2D representation. And outliers can be easily detected from that clusters and backtracking can be done to obtain original outlier from the dataset.
Here is the original research paper by Teuvo Kohonen , the academic researcher who invented SOMs in 1980s.
The Statlog (Australian Credit Approval) Data Set from the UCI machine learning repository contains the credit card approval information.It is a good mix of attributes thus which makes it perfect for SOMs.
The py file of the solution can be found with the name " Fraud_Som.py ".
This involves importing all the necessary python libraries.
Here ,I imported the csv under the variable name 'dataset'.
Further, X corresponds to the all the attributes of the dataset except the last i.e. class - wheather that customer credit card request has been granted or not. y corresponds to the class.
Note: Here y is not the dependent attribute , I have seperated it for the ease of visualization . Since it is Unsupervised Problem so I will trin my Som on X .
All the columns/attributes are scaled with MinMaxScaler with feature range : (0,1)
Since Self Organizing Maps do not have implemetation in scikit learn , so I found an implementation by a developer . you can find the link to his github here. For the ease , I am providing you with the "minisom.py". Just put it in your working directory and you are good to go.
An instance of the Minisom class have the following parameters
- x,y Dimentions of map
- input length
- sigma : radius of influence
- learning rate
Using random weights , neural network is initialized and then trained over 100 iterations .
Here the Map is visualized .
The above picture shows all the winning nodes in each case . As per the color bar more whiter the node , more the mean inter-neuron distance i.e. neuron is an outlier with possible cases of fraud.
Note: Here I will now use the y. I will plot the y as marker over the winning neurons which will give an idea whether the request of fraudent customer has been accepted or not.
Below image has one white winning neuron with the cases of the "not accepted" request mark.
Here , I am mapping the original X with the Map we formed . And getting the list of the customer (under the white winning neuron) , futher inverse transforming it in its orginal form by using the same scaler object.
So fraud object gave me the list of 23 possible fraudent customers who applied for credit card but got rejected(Red marker) .