Inspiration for Neural Network comes from psychologist and neurobiologist. They wanted to develop computational analogous to neurons. Hence, computational neural network is also called artificial neural network.
Neural Network (NN) has neurons and layers in its architecture. 3 layers in Neural Network are Input Layer , Hidden Layer and Output Layer. Each of these layers have units or neurons in it.
Simple Neural Network Representation
Neural Network - Examples and Applications
Due to complexity of neural network, it has been used less frequently. A number of applications of neural network across industries
Neural Network in Banking and Financial Sefvices
- Measuring Credit Risk of New Applicants: Credit Risk is risk of default by the customers whom a credit facility is approved. Banks and financial institutions build predictive model for assessing credit worthiness of the new applicants. Various techniques are used for building the credit risk scorecard or predictive model. Neural Network is also used for classifying customers into Good and Bad. In this scenario, target variable is binary and type of problem is classification.
- Predicting Loan Recovery Rate: Even after using advanced credit scorecard, there is a default. Once customers are defaulted on their loan repayment, the financial institutions aim to recover as much money as possible (by abiding regulatory and legal rules) from the defaulted customers. The recovery rate ( complement of loss given default) is fraction of outstanding balances recovered from the defaulted customers. Neural Network based non-parametric model is used for forecasting bank recoveries.
- Insurance Loss Reserve: In insurance, estimating future cash reserve requirement is crucial to optimize operations. The cash reserve requirement depends on future claim volumes and claim amount. Artificial Neural Network (ANN) could be used for forecasting future claims.
Neural Network is also used for retail - store segmentation, forecasting aggregate sales volume and predicting responders for loyalty mailing.
Neural Network Algorithms
A neural network architecture has input, hidden and output layers and each layer has processing unit(s).
Each of the processing unit has inputs along with their weights (for assigning different level of importance to inputs). The inputs along with weights are aggregated and appropriate transformation (activation function) is applied to the aggregated input.
Based on the sample data, the weights have to be estimated. There are various algorithms to training the network. One of the commonly used neural network algorithm is Backpropagation.
Using initial weights, the target state/labels are estimated using the neural network. The estimate labels are compared against target or actual labels. The gap is called Error and the error is back propagated to improve the weights and reduce the error.
Neural Network Example
A marketing department of a bank runs various marketing campaigns for cross-selling products, customer retention and customer services. In this blog, we will use Marketing Data sample. In this example, the bank wanted to cross-sell term depoisit product to its customers.
Contacting all customers is costly and does not create good customer experience. So, the bank wanted to build a predictive model which will identify customers who are more likely to respond to term deport cross sell campaign. More details on data preparation for predictive modeling.
It is an example of supervised learning. Target variable: Whether a customer is responding to a cross sell campaign. Independent Variables:
age : Age of customer duration: Last cotact duration in second Job Level: Job Levels
Neural Network(NN) is used for building a predictive model.
Neural Network in R
R has at least two packages on neural network. These are nnet and neuralnet . nnet has feed-forward neural networks with a single hidden layer network algorithm implementation.
neuralnet has algorithm for backpropagation with many more features.
neuralnet function within neuralnet package can be used for training the neural network.
Similarly, nnet function from nnet package could be used for training feed-forward neural networks with a single hidden layer
In this blog, we will focus on simple feed forward neural network. Next blog will focus on backward propagation naural network with many complexities.
# Trainin Network
s1.nn <- neuralnet(cross.resp~age,
hidden = 0,
threshold = 0.01,
# Plot Neural Network
This is the simplest Neural Network example. Only one input layer and one output layer with a single variable. Blue line shows Bias.
We can check the accuracy of the result.
We can calculate predicted response values using trained neural network.
# Train sample creation with 20000 observations
testData <- termCrossSell[sample(20000),c('age','cross.resp')]
Compute the predicted values based on the trained network on the new sample. compute function is used.
# Predicted Response
pred.resp <-compute(s1.nn, testData$age)
In the input samples, cross sell response % is 3%. So, top 3% are tagged as 1 in the test data frame.
# Find cut off
sort(pred.resp$net.result,decreasing = T)
# Create predicted target value as 1 or 0
pred.resp.level <- ifelse(pred.resp$net.result >0.1283,1,0)
## 0 1
## 18968 1032
Prediction accuracy check using confusion matrix. More details on Model Performance Statistics
## Confusion Matrix and Statistics
## Prediction 0 1
## 0 18106 862
## 1 980 52
## Accuracy : 0.9079
## 95% CI : (0.9038079, 0.9118731)
## No Information Rate : 0.9543
## P-Value [Acc > NIR] : 1.000000000
## Kappa : 0.0052251
## Mcnemar's Test P-Value : 0.006408847
## Sensitivity : 0.05689278
## Specificity : 0.94865346
## Pos Pred Value : 0.05038760
## Neg Pred Value : 0.95455504
## Prevalence : 0.04570000
## Detection Rate : 0.00260000
## Detection Prevalence : 0.05160000
## Balanced Accuracy : 0.50277312
## 'Positive' Class : 1
Interesting the accuracy level is 90% even with single variable and very simple neural network.