1 of 33

Bank Loan Case Study�

Final project 2.

2 of 33

Summary:

  • Being a company which provides loan to the general public its become very important to understand the customer.
  • There are different criteria , where we can predict the customer wheather they will repay the money or not.
  • To find the genuine customer as the earlier stage its becomes a important task, as the company don’t want bad debt in terms of that person.
  • Identifying the customer is the crucial task, as there are 2 types of customers:
  • The customers which have no previous records ( here the prediction becomes very difficult as there is no past history) this does not mean he/she is not the genuine person, maybe they become defaulters or they become the potential users.
  • If the applicant is not likely to repay the loan, i.e. he/she is likely to default, then approving the loan may lead to a financial loss for the company.

3 of 33

Continue…

  • Based on the data, it totally depends whether their application will reject ar accepted by the organization.
  • When any person file the request there are different scenario where any company or client has to work upon:-
  • Refused: The application will be refused if the applicant does not meet with the requirement set by the company.
  • Accepted: The company has accepted the loan request and they can process further for the final payment.
  • Unused offer: As the application moved ahead and meet with different process and at the time of approaching different stages the application does not meet with the requirement then the application got cancelled.
  • Cancelled: Sometimes client cancelled their own application, might they have changed their mind or might they are getting higher rate of interest or may be with different reasons.

4 of 33

Continue..

  • Here we has to understand thoroughly the importance of Risk analytics.
  • Identifying of those applicants where there is a chance of getting loss Using EDA is very important and the main purpose of this project.
  • The company can utilize this knowledge for its portfolio and risk assessment.

​

5 of 33

Task1: Present the overall approach of the analysis. Mention the problem statement and the analysis approach briefly�

  • As we discussed the problem what the companies are facing with their customers to find the right person for loan procedures.
  • For solving this problem, we have to go through to our dataset and see which user has how much capacity to take hoe much amount or the application need to ignored.
  • The study of risk analysis is important and as well as well as EDA also.
  • The steps are told in the previous slides.
  • Approach is very straight and simple we just need to follow some rules and need to stick on it.

​

6 of 33

Task2: Identify the missing data and use appropriate method to deal with it. (Remove columns/or replace it with an appropriate value)

  • In this dataset we can see that there is lots of noise in terms of null values and with redundant data.
  • There is also a missing data, so what we have to do is, first we will how much missing data we have my using graphs.
  • There are columns which are not needed, which determine the loan will be approved or not like email column, this is not a mandatory column by which the company can decide whether they provide loan to them or not.
  • There are values which needs to standardization process in order to compare the values in the runtime.
  • The memory consumption is also very high, by removing column memory can be released a lot.

7 of 33

Finding and removing columns:-

  • There are more than 50+ columns which needs to be drop as they are not in use nor they are providing any insights to the company or they are correlating with each other.
  • After deleting all those columns we have very less column left but containing the actual information , for better future prediction.
  • The memory also has been released.
  • The columns which are deleted they are not providing the actual information which we want, ex LivingApartment_avg, Nonlivingapartment etc, these are the columns with blank values and missing values.
  • There are many columns which are not connected to each other or not providing the core information in terms of human data, or human nature , by which client decide further decisions.

8 of 33

Remaining columns:

No

Column

Count

Data_type

0

SK_ID_CURR

Not_null

int64

1

SK_ID_CURR

Not_null

int64

2

NAME_CONTRACT_TYPE

Not_null

object

3

AMT_ANNUITY

Not_null

float64

4

AMT_APPLICATION

Not_null

float64

5

AMT_CREDIT

Not_null

float64

6

AMT_GOODS_PRICE

Not_null

float64

7

NAME_CASH_LOAN_PURPOSE

Not_null

object

8

NAME_CONTRACT_STATUS

Not_null

object

9

DAYS_DECISION

Not_null

Int64

10

NAME_PAYMENT_TYPE

Not_null

object

11

CODE_REJECT_REASON

Not_null

object

12

NAME_CLIENT_TYPE

Not_null

object

13

NAME_GOODS_CATEGORY

Not_null

object

9 of 33

Continue

No

Column

Count

Data_type

14

NAME_FAMILY_STATUS

not_null

Float64

15

NAME_HOUSING_TYPE

not_null

float64

16

REGION_POPULATION_RELATIVE

not_null

Int

17

DAYS_BIRTH

not_null

object

18

DAYS_EMPLOYED

not_null

object

19

DAYS_REGISTRATION

not_null

float64

20

DAYS_ID_PUBLISH

not_null

int64

21

OCCUPATION_TYPE

not_null

float64

22

CNT_FAM_MEMBERS

not_null

object

23

REGION_RATING_CLIENT

not_null

int64

24

REGION_RATING_CLIENT_W_CITY

not_null

int64

25

WEEKDAY_APPR_PROCESS_START

not_null

int64

26

HOUR_APPR_PROCESS_START

not_null

object

27

REG_REGION_NOT_LIVE_REGION

not_null

float

10 of 33

Null columns:

  • There are many columns whose value are null or the values are missing.
  • So we need to find all those columns which are providing less than 20% of value.
  • So we need to plot the values accordingly and to find all the values.
  • First we have to find the total empty rows columns in the dataset, then we will find the average null values in each column.
  • According to universal approach lets take 40% as a base percentage less than 40% would be deleted else they will remain in the dataset.
  • In the next slide we will se how much percentage we got in each column, further we will check which columns are more than or equals to 40% of null values.
  • Here we got 11 columns in total.
  • These 11 columns can be deleted and memory can be released.

11 of 33

Column percentage %:-

Column_name

Null values %

AMT_DOWN_PAYMENT

53.636480

RATE_DOWN_PAYMENT

53.636480

RATE_INTEREST_PRIMARY

99.643698

RATE_INTEREST_PRIVILEGED

99.643698

NAME_TYPE_SUITE

49.119754

DAYS_FIRST_DRAWING

40.298129

DAYS_FIRST_DUE

�40.298129

DAYS_LAST_DUE_1ST_VERSION

40.298129

DAYS_LAST_DUE

40.298129

NFLAG_INSURED_ON_APPROVAL

40.298129

​

​

12 of 33

Task:-Identify if there is data imbalance in the data. Find the ratio of data imbalance.�Hint: Since there are a lot of columns, you can run your analysis in loops for the appropriate columns and find the insights.��

  • In this dataset, there is a lot of data which is not appropriate for the evaluation.
  • There is a column in the dataset Days_id_publish where there is a negative values as date cannot be in negative, so we ned to change the data.
  • We have calculate age also in order for the loan personnel, which determine wheather they are eligible for loan approval or not.
  • For this we need to use standardization technique to change the dataset accordingly which can be processed further.
  • Formula: (X- mean)/Standard deviation.
  • Using above formula we can calculate the standardization by which we can process normalization process.

13 of 33

Converting negative values into positive:-

  • Date_col=[‘Days_birth’,’days_employed’,’days_registration’,’days_id_publish’] for col in date_col:applicationDF[col]= abs(applicationDF[col])
  • We also need to find what is the percentage average salary who are applying for the loan and also their age with income and how much amount they have borrowed.

​

Amt_credited

Range

200k-300k

17.82

300k-400k

8.56

400k-500k

10.41

500k-600k

11.13

600k-700k

7.82

700k-800k

6.24

800k-900k

7.08

900k-1M

2.90

1M Above

16.25

14 of 33

Continue…

  • From the last table we got to know that more than 16% people have more than 1 million income.
  • This clearly indicates that if they provide loan to these people there are very less chances of getting bad debts in future.
  • Now we have to find the age criteria which are getting loan.

Age_group

Percentage

0-20

0

20-30

17

40-50

24

30-40

27

50 above

50

​

​

15 of 33

Continue:

  • Now we have to see the datatype of the columns to see the column must have the same datatype or equivalent datatype.’

​

Column

no

Datatype

SK_ID_CURR

1

int64

TARGET

2

int64

NAME_CONTRACT_TYPE

3

category

CODE_GENDER

4

category

FLAG_OWN_CAR

5

category

..

..

​

..

..

​

..

..

​

..

.

​

YEARS_EMPLOYED

51

float64

EMPLOYMENT_YEAR

52

int64

16 of 33

Converting negative days into positive days

  • We need to make this changes by using Categorical bin column from Days_decision column.

​

Days_decision_group

Percentage

0-400

37

400-800

22

800-1200

12

1200-1600

7

1600-2000

5

2000-2400

5

2400-2800

6

2800-3200

1

​

​

17 of 33

TASK:Explain the results of univariate, segmented univariate, bivariate analysis, etc. in business terms.�

1. Univariate:

  • It is a basic kind of analysis technique for statistical data.
  • Uni means one and this means that the data has only one kind of variable.
  • The reason for using this data to describe.
  • The analysis will take data,summarise it, and then find patterns in the data.
  • Univariate is done by looking at the mean,meadian,mode, standard deviation,dispersion etc
  • Univariate analysis is conducted in many ways and most of these ways are of a descriptive nature. These are the Frequency Distribution Tables, Frequency Polygons, Histograms, Bar Charts and Pie Charts

​

18 of 33

Continue:

  • Types of univariate:-
  • Summary Statistics
  • Measures of Dispersion.
  • Measures of central tendency.
  • Frequency distribution table.
  • Bar chart.
  • Histogram.
  • Frequency Polygon.
  • Pie Chart.

19 of 33

Continue.

  • 1. Summary Statistics
  • The most common method for performing univariate analysis is summary statistics.
  • Two common types of statistics are:-
  • Measures of Dispersion: These numbers describe how evenly distributed the values are in a dataset.
  • Range -the difference between the max value and min value in a dataset.
  • Standard Deviation- an average measure of the spread.
  • Interquartile Range- the spread of the middle 50% of values.

b) Measures of central tendency: These numbers describe the location of a dataset’s center or the middle value of the data set.

​

20 of 33

Bar chart:-�

  • The bar chart is represented in the form of rectangular bars.
  • The bar will be plotted vertically.
  • The horizontal or the x-axis will represent the category and the vertical y-axis represents the category’s value.
  • The graph will compare various categories.

​

Pie Chart:-

​

  • The pie chart displays the data in a circular format.
  • The graph is divided into pieces where each piece is proportional to the fraction of the complete category.
  • The entire pie is 100 percent and when you add up each of the pie slices then it should also add up to 100.
  • Each slice of the pie in the pie chart is relative to categories size.

​

21 of 33

2.Segmented univariate.

  • Segmented Univariate Analysis is one of the simplest form of visualization.
  • Segmented analysis here means that the data variable is analyzed in subsets and is very useful.
  • It can show the change metric in pattern across the different segments of the same variable.
  • Segmented Univariate analysis can be used to find summary of a single data variable in form of segments.
  • Data Visualization => Advanced Charts => Segmented Univariate Analysis.
  • In this dataset company give loans to the public ,now they have to check their salary and their age to fulfil their loan procedure in order to complete the application.

22 of 33

3. Bivariate analysis

  • Bivariate Analysis is a type of statistical analysis where two variables can be observed.
  • Bi means two where we take two variable at a time.
  • In this analysis, one variable is dependent and the other is independent.
  • Two types:
  • Multivariate: Multivariate analysis is used for multiple variables in the analysis.
  • Univariate analysis: Univariate analysis is used for one variable.

23 of 33

Scatter Plots:-�

  • The data is represented using dots to show the values for two different numeric variables.
  • It is a pictorial representation of data of two different values as shown in the above figure of a graph.
  • In a scatterplot of bivariate data, we use the horizontal or “x-axis” for the independent variable and the vertical as “y-axis” can be said as the dependent variable.
  • The points are not at the same levels so we can predict that it does not have a perfect linear relationship between the two variables.

24 of 33

TASK:Find the top 10 correlation for the Client with payment difficulties and all other cases (Target variable). Note that you have to find the top correlation by segmenting the data frame w.r.t to the target variable and then find the top correlation for each of the segmented data and find if any insight is there. Say, there are 5+1(target) variables in a dataset: Var1, Var2, Var3, Var4, Var5, Target. And if you have to find top 3 correlation, it can be: Var1 & Var2, Var2 & Var3, Var1 & Var3. Target variable will not feature in this correlation as it is a categorical variable and not a continuous variable which is increasing or decreasing.�

  • Strategy is:-
  • 1. Categorical data analysis.
  • a. Categorical segmented Univariate Analysis
  • b. Categorical Bi/Multivariate analysis.
  • Numerical data analysis:
  • Matrix
  • Multivariate analysis.

25 of 33

Imbalance analysis

  • Imbalanced data refers to those types of datasets where the target class has an uneven distribution of observations.
  • Imbalance = applicationDF["TARGET"].value_counts().reset_index() plt.figure(figsize=(10,4)) x= ['Repayer','Defaulter’] sns.barplot(x,"TARGET",data = Imbalance,palette= ['g','r’]) plt.xlabel("Loan Repayment Status") plt.ylabel("Count of Repayers & Defaulters") plt.title("Imbalance Plotting") plt.show()

​

26 of 33

Categorical analysis

Contract type: Revolving loans are just a small fraction (10%) from the total number of loans; in the same time, a larger amount of Revolving loans, comparing with their frequency, are not repaid.

27 of 33

Numerical data analysis:

  1. More than 80% of the loan provided are for amount less than 900,000.
  2. People who get loan for 300-600k tend to default more than others.

​

28 of 33

Multivariate Analysis:-

NAME_INCOME_TYPE

count

mean

std

min

25%

50%

75%

max

Businessman

10.0

6.52

6.27

1.80

2.25

4.95

8.43

22

Commercial associate

71617

2.02

1.49

0.26

1.35

1.80

2.25

180

Maternity leave

5.0

1.40

1.26

0.49

0.67

0.90

1.35

3.60

Pensioner

55362

1.36

0.76

0.25

0.90

1.17

1.66

22.5

State servant

21703

1.79

1.00

0.27

1.12

1.57

2.25

31.5

Student

18.0

1.70

1.06

0.81

1.12

1.57

1.78

5.56

Unemployed

22.0

1.10

0.88

0.26

0.54

0.78

1.35

3.37

Working

158774

1.63

3.07

0.25

1.12

1.35

2.02

1170.0

We can see that business man is the highest and the range with default 95% confidence level close to 4 lakh and above 10 lakh.

29 of 33

Correlation between numeric variable:-�

Var1

Var2

Correlation

AMT_GOODS_PRICE

AMT_CREDIT

0.98

CNT_FAM_MEMBERS

CNT_CHILDREN

0.88

AMT_GOODS_PRICE

AMT_ANNUITY

0.75

AMT_ANNUITY

AMT_CREDIT

0.75

DAYS_EMPLOYED

DAYS_BIRTH

0.58

DAYS_REGISTRATION

DAYS_BIRTH

0.28

FLAG_DOCUMENT_3

DAYS_EMPLOYED

0.27

DEF_60_CNT_SOCIAL_CIRCLE

OBS_60_CNT_SOCIAL_CIRCLE

0.26

DAYS_BIRTH

CNT_CHILDREN

0.25

DAYS_ID_PUBLISH

DAYS_BIRTH

0.25

30 of 33

Continue…

  • Credit amount is highly correlated with amount of goods price which is same as repayers.
  • There is a severe drop in the correlation between total income of the client and the credit amount(0.038) amongst defaulters whereas it is 0.342 among repayers.
  • There is a slight increase in defaulted to observed count in social circle among defaulters(0.264) when compared to repayers(0.254)
  • The loan annuity correlation with credit amount has slightly reduced in defaulters(0.75) when compared to repayers(0.77)

31 of 33

Conclusion:

  • NAME_INCOME_TYPE: Student and Businessmen have no defaults.
  • DAYS_EMPLOYED: Clients with 40+ year experience having less than 1% default rate.
  • AMT_INCOME_TOTAL:Applicant with Income more than 700,000 are less likely to default.
  • REGION_RATING_CLIENT: RATING 1 is safer.
  • NAME_INCOME_TYPE: Student and Businessmen have no defaults.
  • CNT_CHILDREN: People with zero to two children tend to repay the loans.
  • CODE_GENDER: Men are at relatively higher default rate
  • NAME_EDUCATION_TYPE: People with Lower Secondary & Secondary education.
  • REGION_RATING_CLIENT: People who live in Rating 3 has highest defaults.
  • AMT_GOODS_PRICE: When the credit amount goes beyond 3M, there is an increase in defaulters.

​

​

​

32 of 33

Insights:

  • As we come to an end to our research with our dataset and we got to know that 92% of previously cancelled client have repayed the loan on time. So we have to remove them from the list of defaulters so that we have the correct data in order if they want further loan in future, we can assist them with correct information so that the business can grow and move to further heights.
  • And more than 80% of the clients are there, where the bank has refused to provide loans to those customers as through our analysis we got to know that they have potential to repay the loan in the future so, we can move further with their loan application.

33 of 33

������ Thank you.

  • .