Sie sind auf Seite 1von 46

SOURCE CODES

setwd("F:/project")

> getwd()

[1] "F:/project"

> loandata = read_excel("Thera Bank_Personal_Loan_Modelling-dataset-1.xlsx",

+ sheet = "Bank_Personal_Loan_Modelling")

> dim(loandata)

[1] 5000 14

> head(loandata)

# A tibble: 6 x 14

ID `Age (in years)` `Experience (in~ `Income (in K/m~ `ZIP Code`

<dbl> <dbl> <dbl> <dbl> <dbl>

1 1 25 1 49 91107

2 2 45 19 34 90089

3 3 39 15 11 94720

4 4 35 9 100 94112

5 5 35 8 45 91330

6 6 37 13 29 92121

# ... with 9 more variables: `Family members` <dbl>, CCAvg <dbl>, Education <dbl>,

# Mortgage <dbl>, `Personal Loan` <dbl>, `Securities Account` <dbl>, `CD

# Account` <dbl>, Online <dbl>, CreditCard <dbl>

> summary(loandata)

ID Age (in years) Experience (in years) Income (in K/month)

Min. : 1 Min. :23.00 Min. :-3.0 Min. : 8.00

1st Qu.:1251 1st Qu.:35.00 1st Qu.:10.0 1st Qu.: 39.00

Median :2500 Median :45.00 Median :20.0 Median : 64.00

Mean :2500 Mean :45.34 Mean :20.1 Mean : 73.77

3rd Qu.:3750 3rd Qu.:55.00 3rd Qu.:30.0 3rd Qu.: 98.00


Max. :5000 Max. :67.00 Max. :43.0 Max. :224.00

ZIP Code Family members CCAvg Education Mortgage

Min. : 9307 Min. :1.000 Min. : 0.000 Min. :1.000 Min. : 0.0

1st Qu.:91911 1st Qu.:1.000 1st Qu.: 0.700 1st Qu.:1.000 1st Qu.: 0.0

Median :93437 Median :2.000 Median : 1.500 Median :2.000 Median : 0.0

Mean :93153 Mean :2.397 Mean : 1.938 Mean :1.881 Mean : 56.5

3rd Qu.:94608 3rd Qu.:3.000 3rd Qu.: 2.500 3rd Qu.:3.000 3rd Qu.:101.0

Max. :96651 Max. :4.000 Max. :10.000 Max. :3.000 Max. :635.0

NA's :18

Personal Loan Securities Account CD Account Online

Min. :0.000 Min. :0.0000 Min. :0.0000 Min. :0.0000

1st Qu.:0.000 1st Qu.:0.0000 1st Qu.:0.0000 1st Qu.:0.0000

Median :0.000 Median :0.0000 Median :0.0000 Median :1.0000

Mean :0.096 Mean :0.1044 Mean :0.0604 Mean :0.5968

3rd Qu.:0.000 3rd Qu.:0.0000 3rd Qu.:0.0000 3rd Qu.:1.0000

Max. :1.000 Max. :1.0000 Max. :1.0000 Max. :1.0000

CreditCard

Min. :0.000

1st Qu.:0.000

Median :0.000

Mean :0.294

3rd Qu.:1.000

Max. :1.000

> names(loandata)

[1] "ID" "Age (in years)" "Experience (in years)"

[4] "Income (in K/month)" "ZIP Code" "Family members"


[7] "CCAvg" "Education" "Mortgage"

[10] "Personal Loan" "Securities Account" "CD Account"

[13] "Online" "CreditCard"

> sum(is.na(loandata))

[1] 18

> loandata$`Family members`[is.na(loandata$`Family members`)]=mean(loandata$`Family


members`,na.rm=TRUE)

> sum(is.na(loandata))

[1] 0

> correlation = cor(loandata)

> corrplot(correlation, method = "number",number.digits = 2,number.cex = 0.8, tl.offset = 2,tl.cex = 1,


win.graph(4500,4500))

> loans=loandata[,c(-1,-3,-5)]

> summary(loans)

Age (in years) Income (in K/month) Family members CCAvg

Min. :23.00 Min. : 8.00 Min. :1.000 Min. : 0.000

1st Qu.:35.00 1st Qu.: 39.00 1st Qu.:1.000 1st Qu.: 0.700

Median :45.00 Median : 64.00 Median :2.000 Median : 1.500

Mean :45.34 Mean : 73.77 Mean :2.397 Mean : 1.938

3rd Qu.:55.00 3rd Qu.: 98.00 3rd Qu.:3.000 3rd Qu.: 2.500

Max. :67.00 Max. :224.00 Max. :4.000 Max. :10.000

Education Mortgage Personal Loan Securities Account

Min. :1.000 Min. : 0.0 Min. :0.000 Min. :0.0000

1st Qu.:1.000 1st Qu.: 0.0 1st Qu.:0.000 1st Qu.:0.0000

Median :2.000 Median : 0.0 Median :0.000 Median :0.0000

Mean :1.881 Mean : 56.5 Mean :0.096 Mean :0.1044

3rd Qu.:3.000 3rd Qu.:101.0 3rd Qu.:0.000 3rd Qu.:0.0000

Max. :3.000 Max. :635.0 Max. :1.000 Max. :1.0000

CD Account Online CreditCard


Min. :0.0000 Min. :0.0000 Min. :0.000

1st Qu.:0.0000 1st Qu.:0.0000 1st Qu.:0.000

Median :0.0000 Median :1.0000 Median :0.000

Mean :0.0604 Mean :0.5968 Mean :0.294

3rd Qu.:0.0000 3rd Qu.:1.0000 3rd Qu.:1.000

Max. :1.0000 Max. :1.0000 Max. :1.000

> dim(loans)

[1] 5000 11

> d.chebyshev=dist(x=loans,method="maximum")

> d.euc=dist(x=loans,method = "euclidean")

> res.hclust.euc=hclust(d.euc,method = "complete")

> res.hclust.ch=hclust(d.chebyshev,method = "complete")

> cluster.height=res.hclust.euc$height

> cluster.height=sort(cluster.height,decreasing = TRUE)

> plot(cluster.height,pch=20,col="red",main="cluster height",ylab="cluster height")

> lines(cluster.height,lty=2,lwd=2,col="blue")

> par(mfrow=c(2,1))

> plot(res.hclust.euc,labels=as.character(loans[,2]),main="H clust Using Euclidean


Method",xlab="Euclidean distance",ylab="Height")

> rect.hclust(res.hclust.euc,k=3,border = "red")

> plot(res.hclust.ch,labels=as.character(loans[,2]),main="H clust Using Chebychev


Method",xlab="Chebychev Distance",ylab="Height")

> rect.hclust(res.hclust.ch,k=3,border = "red")

> str(loans)

Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 5000 obs. of 11 variables:

$ Age (in years) : num 25 45 39 35 35 37 53 50 35 34 ...

$ Income (in K/month): num 49 34 11 100 45 29 72 22 81 180 ...

$ Family members : num 4 3 1 1 4 4 2 1 3 1 ...

$ CCAvg : num 1.6 1.5 1 2.7 1 0.4 1.5 0.3 0.6 8.9 ...
$ Education : num 1 1 1 2 2 2 2 3 2 3 ...

$ Mortgage : num 0 0 0 0 0 155 0 0 104 0 ...

$ Personal Loan : num 0 0 0 0 0 0 0 0 0 1 ...

$ Securities Account : num 1 1 0 0 0 0 0 0 0 0 ...

$ CD Account : num 0 0 0 0 0 0 0 0 0 0 ...

$ Online : num 0 0 0 0 0 1 1 0 1 0 ...

$ CreditCard : num 0 0 0 0 1 0 0 1 0 0 ...

> loans.scaled=scale(loans)

> loans.scaled

Age (in years) Income (in K/month) Family members CCAvg Education

[1,] -1.77423939 -0.538174951 1.3996851 -0.19336610 -1.0489730

[2,] -0.02952064 -0.864022980 0.5263938 -0.25058550 -1.0489730

[3,] -0.55293627 -1.363656626 -1.2201888 -0.53668251 -1.0489730

[4,] -0.90188002 0.569708351 -1.2201888 0.43604731 0.1416887

[5,] -0.90188002 -0.625067758 1.3996851 -0.53668251 0.1416887

[6,] -0.72740814 -0.972638990 1.3996851 -0.87999891 0.1416887

[7,] 0.66836686 -0.038541305 -0.3468975 -0.25058550 0.1416887

[8,] 0.40665905 -1.124701404 -1.2201888 -0.93721831 1.3323505

[9,] -0.90188002 0.156967513 0.5263938 -0.76556011 0.1416887

[10,] -0.98911595 2.307564509 -1.2201888 3.98365017 1.3323505

[11,] 1.71519811 0.678324360 1.3996851 0.26438911 1.3323505

[12,] -1.42529564 -0.625067758 0.5263938 -1.05165711 0.1416887

[13,] 0.23218717 0.873833178 -0.3468975 1.06546072 1.3323505

[14,] 1.19178248 -0.733683768 1.3996851 0.32160851 0.1416887

[15,] 1.88966998 0.830386774 -1.2201888 0.03551150 -1.0489730

[16,] 1.27901842 -1.124701404 -1.2201888 -0.25058550 1.3323505

[17,] -0.64017220 1.221404410 1.3996851 1.58043533 1.3323505

[18,] -0.29122845 0.156967513 1.3996851 0.26438911 -1.0489730

[19,] 0.05771530 2.589966135 -0.3468975 3.52589497 1.3323505


[20,] 0.84283873 -1.146424606 -1.2201888 -0.82277951 0.1416887

[21,] 0.93007467 -1.059531798 0.0000000 -0.59390191 0.1416887

[22,] 1.01731061 -0.234050123 0.5263938 0.03551150 1.3323505

[23,] -1.42529564 -0.255773325 -1.2201888 -0.42224370 -1.0489730

[24,] -0.11675658 -0.668514162 -0.3468975 -0.70834071 -1.0489730

[25,] -0.81464408 1.699314854 -0.3468975 1.12268012 -1.0489730

[26,] -0.20399252 -0.972638990 0.5263938 -0.82277951 -1.0489730

[27,] -0.46570033 0.200413917 1.3996851 -0.99443771 1.3323505

[28,] 0.05771530 1.829654065 -1.2201888 0.26438911 -1.0489730

[29,] 0.93007467 -0.559898153 -1.2201888 0.14995031 1.3323505

[30,] -0.64017220 0.982449188 -1.2201888 0.77936372 0.1416887

[31,] 1.19178248 -0.842299778 -1.2201888 -0.42224370 1.3323505

[32,] -0.46570033 -0.972638990 -1.2201888 0.03551150 0.1416887

[33,] 0.66836686 -0.711960566 -0.3468975 -0.76556011 1.3323505

[34,] -1.33805970 -1.211594212 0.5263938 -0.59390191 1.3323505

[35,] -1.25082377 -0.516451749 1.3996851 -0.07892730 1.3323505

[36,] 0.23218717 0.156967513 0.5263938 -0.70834071 -1.0489730

[37,] 1.19178248 1.025895592 -1.2201888 0.55048611 -1.0489730

[38,] 0.49389498 -0.060264507 -1.2201888 -0.30780490 1.3323505

[39,] -0.29122845 1.460359632 0.5263938 1.75209353 1.3323505

[40,] -0.64017220 0.135244311 1.3996851 -0.70834071 1.3323505

[41,] 1.01731061 0.222137119 0.5263938 -0.19336610 1.3323505

[42,] -0.98911595 -0.299219729 0.5263938 0.20716971 -1.0489730

[43,] -1.16358783 1.264850814 1.3996851 -0.47946310 0.1416887

[44,] -0.55293627 -0.625067758 -1.2201888 -0.70834071 -1.0489730

[45,] 0.05771530 0.656601158 -1.2201888 2.15262934 -1.0489730

[46,] 1.01731061 -0.473005345 1.3996851 0.32160851 -1.0489730

[47,] -0.55293627 -0.668514162 0.5263938 -0.70834071 0.1416887

[48,] -0.72740814 2.611689337 1.3996851 -0.99443771 1.3323505


[49,] 0.93007467 0.156967513 -0.3468975 1.46599653 1.3323505

[50,] -0.46570033 -0.538174951 -1.2201888 -0.07892730 -1.0489730

[51,] -1.16358783 -1.428826232 1.3996851 -0.70834071 0.1416887

[52,] 1.36625436 1.243127612 -1.2201888 0.55048611 -1.0489730

[53,] -1.33805970 -0.038541305 -1.2201888 -1.05165711 -1.0489730

[54,] 0.40665905 2.524796529 0.5263938 0.09273091 1.3323505

[55,] -1.42529564 -0.646790960 -1.2201888 -0.99443771 1.3323505

[56,] -0.37846439 1.416913228 -0.3468975 3.46867556 -1.0489730

[57,] 0.84283873 -0.972638990 0.5263938 -1.05165711 0.1416887

[58,] 0.93007467 1.243127612 -0.3468975 -0.42224370 1.3323505

[59,] -1.51253158 0.417645937 0.0000000 -0.99443771 -1.0489730

[60,] -1.25082377 2.481350125 -0.3468975 1.46599653 -1.0489730

[61,] 0.31942311 -0.755406970 0.5263938 -0.13614670 0.1416887

[62,] 0.14495123 1.112788400 -1.2201888 2.15262934 -1.0489730

[63,] -0.29122845 -1.124701404 -1.2201888 -0.53668251 -1.0489730

[64,] -0.29122845 -0.907469384 1.3996851 -1.10887652 0.1416887

[65,] 0.14495123 0.678324360 -0.3468975 0.77936372 -1.0489730

[66,] 1.19178248 1.243127612 -1.2201888 1.06546072 -1.0489730

[67,] 1.45349030 0.678324360 -0.3468975 0.49326671 -1.0489730

[68,] 0.66836686 -0.625067758 1.3996851 0.03551150 1.3323505

[69,] 0.14495123 -0.299219729 0.5263938 0.09273091 -1.0489730

[70,] 0.66836686 -1.168147808 1.3996851 -0.99443771 -1.0489730

[71,] -0.29122845 0.895556380 -1.2201888 0.89380252 -1.0489730

[72,] 0.66836686 -0.103710911 1.3996851 -0.53668251 0.1416887

[73,] -0.11675658 1.221404410 -1.2201888 1.75209353 -1.0489730

[74,] -0.37846439 0.243860321 -1.2201888 1.17989952 1.3323505

[75,] -1.51253158 1.330020420 -0.3468975 0.77936372 -1.0489730

[76,] -1.25082377 1.330020420 1.3996851 1.06546072 0.1416887

[77,] 1.10454655 -1.341933424 0.5263938 -0.93721831 1.3323505


[78,] 0.05771530 -0.972638990 0.5263938 -0.82277951 0.1416887

[79,] 0.75560280 1.286574016 -0.3468975 0.37882791 1.3323505

[80,] 0.40665905 -1.189871010 -0.3468975 -0.87999891 -1.0489730

[81,] 1.27901842 -0.711960566 1.3996851 -0.36502430 -1.0489730

[82,] 0.14495123 -0.733683768 0.5263938 0.43604731 0.1416887

[83,] -0.37846439 0.178690715 -1.2201888 1.17989952 1.3323505

[84,] -1.07635189 -0.516451749 -1.2201888 0.26438911 0.1416887

[85,] 0.05771530 -1.211594212 -1.2201888 -0.59390191 1.3323505

[86,] -1.59976752 0.765217168 1.3996851 -0.07892730 1.3323505

[87,] -0.46570033 -0.690237364 1.3996851 0.14995031 0.1416887

[88,] 0.23218717 0.091797907 0.5263938 -0.47946310 -1.0489730

[89,] 1.71519811 -0.494728547 -0.3468975 -0.47946310 -1.0489730

[90,] -1.77423939 0.852109976 1.3996851 0.20716971 1.3323505

Mortgage Personal Loan Securities Account CD Account Online

[1,] -0.5554684 -0.3258427 2.9286223 -0.2535149 -1.2164961

[2,] -0.5554684 -0.3258427 2.9286223 -0.2535149 -1.2164961

[3,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 -1.2164961

[4,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 -1.2164961

[5,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 -1.2164961

[6,] 0.9684153 -0.3258427 -0.3413892 -0.2535149 0.8218687

[7,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 0.8218687

[8,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 -1.2164961

[9,] 0.4670084 -0.3258427 -0.3413892 -0.2535149 0.8218687

[10,] -0.5554684 3.0683519 -0.3413892 -0.2535149 -1.2164961

[11,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 -1.2164961

[12,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 0.8218687

[13,] -0.5554684 -0.3258427 2.9286223 -0.2535149 -1.2164961

[14,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 0.8218687

[15,] -0.5554684 -0.3258427 2.9286223 -0.2535149 -1.2164961


[16,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 0.8218687

[17,] 0.7619536 3.0683519 -0.3413892 -0.2535149 -1.2164961

[18,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 -1.2164961

[19,] -0.5554684 3.0683519 -0.3413892 -0.2535149 -1.2164961

[20,] -0.5554684 -0.3258427 2.9286223 -0.2535149 -1.2164961

[21,] 0.5358290 -0.3258427 -0.3413892 -0.2535149 0.8218687

[22,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 0.8218687

[23,] 2.0007236 -0.3258427 -0.3413892 -0.2535149 0.8218687

[24,] 1.0470673 -0.3258427 2.9286223 -0.2535149 -1.2164961

[25,] 1.0077413 -0.3258427 -0.3413892 -0.2535149 -1.2164961

[26,] 0.3981878 -0.3258427 -0.3413892 -0.2535149 0.8218687

[27,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 -1.2164961

[28,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 0.8218687

[29,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 0.8218687

[30,] -0.5554684 3.0683519 -0.3413892 3.9437520 0.8218687

[31,] 0.6439755 -0.3258427 -0.3413892 -0.2535149 0.8218687

[32,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 0.8218687

[33,] 1.3420126 -0.3258427 -0.3413892 -0.2535149 -1.2164961

[34,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 -1.2164961

[35,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 0.8218687

[36,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 -1.2164961

[37,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 -1.2164961

[38,] 1.3911701 -0.3258427 -0.3413892 -0.2535149 -1.2164961

[39,] -0.5554684 3.0683519 2.9286223 3.9437520 0.8218687

[40,] 2.2465112 -0.3258427 -0.3413892 -0.2535149 0.8218687

[41,] -0.5554684 -0.3258427 2.9286223 -0.2535149 -1.2164961

[42,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 -1.2164961

[43,] 3.4951127 3.0683519 -0.3413892 -0.2535149 0.8218687

[44,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 0.8218687


[45,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 0.8218687

[46,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 -1.2164961

[47,] 0.9487523 -0.3258427 -0.3413892 -0.2535149 0.8218687

[48,] 1.5189797 3.0683519 2.9286223 3.9437520 0.8218687

[49,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 -1.2164961

[50,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 -1.2164961

[51,] -0.5554684 -0.3258427 2.9286223 -0.2535149 0.8218687

[52,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 0.8218687

[53,] 1.4796537 -0.3258427 -0.3413892 -0.2535149 -1.2164961

[54,] 1.8040934 3.0683519 -0.3413892 -0.2535149 0.8218687

[55,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 0.8218687

[56,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 0.8218687

[57,] -0.5554684 -0.3258427 2.9286223 3.9437520 0.8218687

[58,] -0.5554684 3.0683519 -0.3413892 -0.2535149 -1.2164961

[59,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 -1.2164961

[60,] 3.9178675 -0.3258427 -0.3413892 -0.2535149 -1.2164961

[61,] -0.5554684 -0.3258427 2.9286223 -0.2535149 0.8218687

[62,] 0.5456605 -0.3258427 2.9286223 -0.2535149 -1.2164961

[63,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 -1.2164961

[64,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 0.8218687

[65,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 -1.2164961

[66,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 0.8218687

[67,] 2.7479181 -0.3258427 -0.3413892 -0.2535149 -1.2164961

[68,] 0.7422906 -0.3258427 2.9286223 -0.2535149 -1.2164961

[69,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 0.8218687

[70,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 0.8218687

[71,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 -1.2164961

[72,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 0.8218687

[73,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 -1.2164961


[74,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 0.8218687

[75,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 -1.2164961

[76,] -0.5554684 3.0683519 -0.3413892 3.9437520 0.8218687

[77,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 -1.2164961

[78,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 -1.2164961

[79,] -0.5554684 3.0683519 -0.3413892 -0.2535149 -1.2164961

[80,] 0.6046495 -0.3258427 -0.3413892 -0.2535149 0.8218687

[81,] 1.1552139 -0.3258427 -0.3413892 -0.2535149 0.8218687

[82,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 0.8218687

[83,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 0.8218687

[84,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 -1.2164961

[85,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 0.8218687

[86,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 -1.2164961

[87,] 0.6833016 -0.3258427 -0.3413892 -0.2535149 -1.2164961

[88,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 0.8218687

[89,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 0.8218687

[90,] -0.5554684 -0.3258427 -0.3413892 -0.2535149 -1.2164961

CreditCard

[1,] -0.6452498

[2,] -0.6452498

[3,] -0.6452498

[4,] -0.6452498

[5,] 1.5494774

[6,] -0.6452498

[7,] -0.6452498

[8,] 1.5494774

[9,] -0.6452498

[10,] -0.6452498

[11,] -0.6452498
[12,] -0.6452498

[13,] -0.6452498

[14,] -0.6452498

[15,] -0.6452498

[16,] 1.5494774

[17,] -0.6452498

[18,] -0.6452498

[19,] -0.6452498

[20,] 1.5494774

[21,] -0.6452498

[22,] -0.6452498

[23,] -0.6452498

[24,] -0.6452498

[25,] 1.5494774

[26,] -0.6452498

[27,] -0.6452498

[28,] 1.5494774

[29,] 1.5494774

[30,] 1.5494774

[31,] -0.6452498

[32,] -0.6452498

[33,] -0.6452498

[34,] -0.6452498

[35,] -0.6452498

[36,] -0.6452498

[37,] 1.5494774

[38,] -0.6452498

[39,] -0.6452498

[40,] -0.6452498
[41,] -0.6452498

[42,] -0.6452498

[43,] -0.6452498

[44,] -0.6452498

[45,] 1.5494774

[46,] 1.5494774

[47,] -0.6452498

[48,] 1.5494774

[49,] 1.5494774

[50,] 1.5494774

[51,] -0.6452498

[52,] -0.6452498

[53,] -0.6452498

[54,] -0.6452498

[55,] -0.6452498

[56,] -0.6452498

[57,] -0.6452498

[58,] -0.6452498

[59,] -0.6452498

[60,] -0.6452498

[61,] -0.6452498

[62,] -0.6452498

[63,] -0.6452498

[64,] -0.6452498

[65,] -0.6452498

[66,] 1.5494774

[67,] -0.6452498

[68,] -0.6452498

[69,] 1.5494774
[70,] -0.6452498

[71,] 1.5494774

[72,] -0.6452498

[73,] 1.5494774

[74,] 1.5494774

[75,] 1.5494774

[76,] 1.5494774

[77,] -0.6452498

[78,] -0.6452498

[79,] -0.6452498

[80,] -0.6452498

[81,] 1.5494774

[82,] -0.6452498

[83,] -0.6452498

[84,] -0.6452498

[85,] -0.6452498

[86,] -0.6452498

[87,] -0.6452498

[88,] -0.6452498

[89,] -0.6452498

[90,] 1.5494774

[ reached getOption("max.print") -- omitted 4910 rows ]

attr(,"scaled:center")

Age (in years) Income (in K/month) Family members CCAvg

45.338400 73.774200 2.397230 1.937938

Education Mortgage Personal Loan Securities Account

1.881000 56.498800 0.096000 0.104400

CD Account Online CreditCard

0.060400 0.596800 0.294000


attr(,"scaled:scale")

Age (in years) Income (in K/month) Family members CCAvg

11.4631656 46.0337293 1.1450933 1.7476590

Education Mortgage Personal Loan Securities Account

0.8398691 101.7138021 0.2946207 0.3058093

CD Account Online CreditCard

0.2382503 0.4905893 0.4556375

> seed=1000

> set.seed(seed)

> clust1=kmeans(x=loans.scaled,centers = 2,nstart=5)

> clusplot(loans.scaled,clust1$cluster,color=TRUE,shade=TRUE,labels = 2,lines = 1)

> twss=rep(0.5)

> (k in 1:5)
{set.seed(seed)clust2=kmeans(x=loans.scaled,centres=k,nstart=5)twss[k]=clust1$tot.withinss}

> print(twss)

[1] 0.5

> plot(c(1:5),twss,type = "b")

> set.seed(seed)

> nc=NbClust (loans,min.nc=2,max.nc=5,method="kmeans")

*** : The Hubert index is a graphical method of determining the number of clusters.

In the plot of Hubert index, we seek a significant knee that corresponds to a

significant increase of the value of the measure i.e the significant peak in Hubert

index second differences plot.

*** : The D index is a graphical method of determining the number of clusters.

In the plot of D index, we seek a significant knee (the significant peak in Dindex

second differences plot) that corresponds to a significant increase of the value of

the measure.
*******************************************************************

* Among all indices:

* 8 proposed 2 as the best number of clusters

* 2 proposed 3 as the best number of clusters

* 12 proposed 4 as the best number of clusters

* 2 proposed 5 as the best number of clusters

***** Conclusion *****

* According to the majority rule, the best number of clusters is 4

*******************************************************************

> table(nc$Best.n[1,])

0 2 3 4 5

2 8 2 12 2

> set.seed(seed)

> clust3=kmeans(x=loans.scaled,centers=4,nstart=5)

> clusplot(loans.scaled,clust3$cluster,color=TRUE,shade=TRUE,labels = 2,lines = 1,main = "Final


Cluster")

> #CART

> set.seed(111)

> str(loans)

Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 5000 obs. of 11 variables:

$ Age (in years) : num 25 45 39 35 35 37 53 50 35 34 ...

$ Income (in K/month): num 49 34 11 100 45 29 72 22 81 180 ...

$ Family members : num 4 3 1 1 4 4 2 1 3 1 ...

$ CCAvg : num 1.6 1.5 1 2.7 1 0.4 1.5 0.3 0.6 8.9 ...
$ Education : num 1 1 1 2 2 2 2 3 2 3 ...

$ Mortgage : num 0 0 0 0 0 155 0 0 104 0 ...

$ Personal Loan : num 0 0 0 0 0 0 0 0 0 1 ...

$ Securities Account : num 1 1 0 0 0 0 0 0 0 0 ...

$ CD Account : num 0 0 0 0 0 0 0 0 0 0 ...

$ Online : num 0 0 0 0 0 1 1 0 1 0 ...

$ CreditCard : num 0 0 0 0 1 0 0 1 0 0 ...

> prop.table(table(loans$`Personal Loan`))

0 1

0.904 0.096

> sample=sample.split(loans,SplitRatio = 0.7)

> CARTtrain = subset(loans,sample = TRUE)

> CARTtest = subset(loans,sample = FALSE)

> table(CARTtrain$`Personal Loan`)

0 1

4520 480

> sum(CARTtrain$`Personal Loan` == "1")/nrow(CARTtrain)

[1] 0.096

> CARTtrain=train.data

> CARTtest=test.data

> r.ctrl = rpart.control(minsplit=100, minbucket = 10, cp = 0, xval = 10)

> cart.model = rpart(formula = Personal Loan,~. , data = CARTtrain, method = class, control = r.ctrl)

> cart.model

> cartmodel$variable.importance

> cart.model=rpart(formula =CARTtrain$`Personal Loan` ~ ., data = CARTtrain, method = "class",


control = r.ctrl)

> cart.model
n= 5000

node), split, n, loss, yval, (yprob)

* denotes terminal node

1) root 5000 480 0 (0.904000000 0.096000000)

2) Income (in K/month)< 113.5 4021 84 0 (0.979109674 0.020890326)

4) CCAvg< 2.95 3723 13 0 (0.996508192 0.003491808) *

5) CCAvg>=2.95 298 71 0 (0.761744966 0.238255034)

10) CD Account< 0.5 272 51 0 (0.812500000 0.187500000) *

11) CD Account>=0.5 26 6 1 (0.230769231 0.769230769) *

3) Income (in K/month)>=113.5 979 396 0 (0.595505618 0.404494382)

6) Education< 1.5 635 69 0 (0.891338583 0.108661417)

12) Family members< 2.698615 566 0 0 (1.000000000 0.000000000) *

13) Family members>=2.698615 69 0 1 (0.000000000 1.000000000) *

7) Education>=1.5 344 17 1 (0.049418605 0.950581395)

14) Income (in K/month)< 116.5 30 13 0 (0.566666667 0.433333333) *

15) Income (in K/month)>=116.5 314 0 1 (0.000000000 1.000000000) *

> library(rpart)

> install.packages("rpart.plot")

Error in install.packages : Updating loaded packages

> fancyRpartPlot(cart.model)

> cart.model$variable.importance

Education Income (in K/month) Family members CCAvg

316.315958 252.054129 205.761806 122.528029

CD Account Mortgage Age (in years)

63.877219 27.765002 2.994183

> view(cart.model$variable.importance)

> round(cart.model$variable.importance,4)
Education Income (in K/month) Family members CCAvg

316.3160 252.0541 205.7618 122.5280

CD Account Mortgage Age (in years)

63.8772 27.7650 2.9942

> cart.model$cptable

CP nsplit rel error xerror xstd

1 0.322916667 0 1.0000000 1.0000000 0.04339739

2 0.143750000 2 0.3541667 0.3604167 0.02692374

3 0.014583333 3 0.2104167 0.2187500 0.02112247

4 0.008333333 5 0.1812500 0.1895833 0.01969205

5 0.000000000 6 0.1729167 0.1729167 0.01882188

> print(cart.model)

n= 5000

node), split, n, loss, yval, (yprob)

* denotes terminal node

1) root 5000 480 0 (0.904000000 0.096000000)

2) Income (in K/month)< 113.5 4021 84 0 (0.979109674 0.020890326)

4) CCAvg< 2.95 3723 13 0 (0.996508192 0.003491808) *

5) CCAvg>=2.95 298 71 0 (0.761744966 0.238255034)

10) CD Account< 0.5 272 51 0 (0.812500000 0.187500000) *

11) CD Account>=0.5 26 6 1 (0.230769231 0.769230769) *

3) Income (in K/month)>=113.5 979 396 0 (0.595505618 0.404494382)

6) Education< 1.5 635 69 0 (0.891338583 0.108661417)

12) Family members< 2.698615 566 0 0 (1.000000000 0.000000000) *

13) Family members>=2.698615 69 0 1 (0.000000000 1.000000000) *

7) Education>=1.5 344 17 1 (0.049418605 0.950581395)

14) Income (in K/month)< 116.5 30 13 0 (0.566666667 0.433333333) *


15) Income (in K/month)>=116.5 314 0 1 (0.000000000 1.000000000) *

> cptable.frame=as.data.frame(cart.model$cptable)

> cptable.frame$cp.deci=round(cptable.frame$CP,4)

> cptable.frame

CP nsplit rel error xerror xstd cp.deci

1 0.322916667 0 1.0000000 1.0000000 0.04339739 0.3229

2 0.143750000 2 0.3541667 0.3604167 0.02692374 0.1438

3 0.014583333 3 0.2104167 0.2187500 0.02112247 0.0146

4 0.008333333 5 0.1812500 0.1895833 0.01969205 0.0083

5 0.000000000 6 0.1729167 0.1729167 0.01882188 0.0000

> plotcp(cart.model,main="Size of Tree")

> predCT=predict(cart.model,CARTtrain[,-7],type = "class")

> predCTrain=predict(cart.model,CARTtrain[,-7])

> tab2=table(CARTtrain$`Personal Loan`,predCT)

> sum(diag(tab2))/sum(tab2)

[1] 0.9834

> m1_pruned = prune(cart.model, cp = 0.05)

> m1_pruned

n= 5000

node), split, n, loss, yval, (yprob)

* denotes terminal node

1) root 5000 480 0 (0.90400000 0.09600000)

2) Income (in K/month)< 113.5 4021 84 0 (0.97910967 0.02089033) *

3) Income (in K/month)>=113.5 979 396 0 (0.59550562 0.40449438)

6) Education< 1.5 635 69 0 (0.89133858 0.10866142)

12) Family members< 2.698615 566 0 0 (1.00000000 0.00000000) *

13) Family members>=2.698615 69 0 1 (0.00000000 1.00000000) *


7) Education>=1.5 344 17 1 (0.04941860 0.95058140) *

> fancyRpartPlot(m1_pruned)

Random Forest

## $ Experience : num 1 15 9 8 13 24 10 39 5 32 ...

## $ Income : num 49 11 100 45 29 22 81 105 45 40 ...

## $ ZipCode : num 91107 94720 94112 91330 92121 ...

## $ FamilySize : num 41 1 44 1 34 34 ...

## $ CCAvg : num 1.6 1 2.7 1 0.4 0.3 0.6 2.4 0.1


2.5 ...

## $ Education : num 11 2 22 3 23 22 ...

## $ Mortgage : num 0 0 0 0 155 0 104 0 0 0 ...

## $ AcceptLoanOffer : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1

...

## $ SecuritiesAccountExist: num 1 0 0 0 0 0 0
0 0 0 ...

## $ DepositAccountExist : num 0 0 0 0 0 0
0 0 0 0 ...

## $ OnlineBankingExist : num 0 0 0 0 1 0
1 0 1 1 ...

## $ CreditCardExist : num 0 0 0 1 0 1 0
0 0 0 ...

## [1] 0.096

## [1] 0.096 ##

## Call:

## randomForest(formula = trainDSRF$AcceptLoanOffer ~ ., data = trainDSRF, ntree = 600, mtry =


4, nodesize = 70, importance = TRUE)

## Type of random forest: classification ## Number of trees: 600

## No. of variables tried at each split: 4 ##


## OOB estimate of error rate: 1.71% ## Confusion matrix:

## 0 1 class.error

## 0 3156 8 0.002528445

## 1 52 284 0.154761905

## [19,] 0.02400686 0.005690800 0.1964286

## [20,] 0.02400686 0.005690800 0.1964286

## [21,] 0.02286368 0.005690800 0.1845238

## [22,] 0.02200629 0.004426178 0.1875000

## [23,] 0.02257788 0.004110022 0.1964286

## [24,] 0.02086310 0.003477711 0.1845238

## [25,] 0.02171429 0.003792668 0.1904762

## [26,] 0.02285714 0.004424779 0.1964286

## [27,] 0.02228571 0.003792668 0.1964286

## [28,] 0.02285714 0.003476612 0.2053571

## [29,] 0.02085714 0.003476612 0.1845238

## [30,] 0.02114286 0.003476612 0.1875000

## [31,] 0.02085714 0.003792668 0.1815476

## [32,] 0.02057143 0.003476612 0.1815476

## [33,] 0.02028571 0.003160556 0.1815476

## [34,] 0.02057143 0.003160556 0.1845238

## [35,] 0.02085714 0.003792668 0.1815476

## [36,] 0.02085714 0.003476612 0.1845238

## [37,] 0.02057143 0.003792668 0.1785714

## [38,] 0.02057143 0.003792668 0.1785714

## [39,] 0.02057143 0.003476612 0.1815476

## [40,] 0.01942857 0.003160556 0.1726190

## [41,] 0.01971429 0.003792668 0.1696429

## [42,] 0.01971429 0.003476612 0.1726190


## [43,] 0.01942857 0.003476612 0.1696429

## [44,] 0.01914286 0.003792668 0.1636905

## [45,] 0.01971429 0.003792668 0.1696429

## [46,] 0.01885714 0.003476612 0.1636905

## [47,] 0.01914286 0.004108723 0.1607143

## [48,] 0.01857143 0.003476612 0.1607143

## [49,] 0.01914286 0.004108723 0.1607143

## [50,] 0.01942857 0.003476612 0.1696429

## [51,] 0.01885714 0.003792668 0.1607143

## [52,] 0.01885714 0.003160556 0.1666667

## [53,] 0.01885714 0.003476612 0.1636905

## [54,] 0.01828571 0.003476612 0.1577381

## [55,] 0.01828571 0.003160556 0.1607143

## [56,] 0.01857143 0.003476612 0.1607143

## [57,] 0.01828571 0.003476612 0.1577381

## [58,] 0.01828571 0.003792668 0.1547619

## [59,] 0.01942857 0.004108723 0.1636905

## [60,] 0.01885714 0.004108723 0.1577381

## [61,] 0.01942857 0.004108723 0.1636905

## [62,] 0.01971429 0.003792668 0.1696429

## [63,] 0.01971429 0.003476612 0.1726190

## [64,] 0.01971429 0.004108723 0.1666667

## [65,] 0.01914286 0.003792668 0.1636905

## [66,] 0.02028571 0.004108723 0.1726190

## [67,] 0.01971429 0.004108723 0.1666667

## [68,] 0.01971429 0.004108723 0.1666667

## [69,] 0.02000000 0.004108723 0.1696429


## [70,] 0.02000000 0.004108723 0.1696429

## [71,] 0.02057143 0.004108723 0.1755952

## [72,] 0.02057143 0.004108723 0.1755952

## [73,] 0.02000000 0.004108723 0.1696429

## [74,] 0.02171429 0.004108723 0.1875000

## [75,] 0.02028571 0.003792668 0.1755952

## [76,] 0.02085714 0.003792668 0.1815476

## [77,] 0.02028571 0.004108723 0.1726190

## [78,] 0.02028571 0.003792668 0.1755952

## [79,] 0.01942857 0.003792668 0.1666667

## [80,] 0.01942857 0.003792668 0.1666667

## [81,] 0.01971429 0.003792668 0.1696429

## [82,] 0.02000000 0.003792668 0.1726190

## [83,] 0.01942857 0.003792668 0.1666667

## [84,] 0.01914286 0.004108723 0.1607143

## [85,] 0.01942857 0.003792668 0.1666667

## [86,] 0.01914286 0.003792668 0.1636905

## [87,] 0.01885714 0.003792668 0.1607143

## [88,] 0.01885714 0.003792668 0.1607143

## [89,] 0.01942857 0.004424779 0.1607143

## [90,] 0.01942857 0.004424779 0.1607143

## [91,] 0.01942857 0.004108723 0.1636905

## [92,] 0.01942857 0.004424779 0.1607143

## [93,] 0.01914286 0.003792668 0.1636905

## [94,] 0.01942857 0.004108723 0.1636905

## [95,] 0.01885714 0.003792668 0.1607143

## [96,] 0.01885714 0.004108723 0.1577381

## [97,] 0.01828571 0.003792668 0.1547619

## [98,] 0.01885714 0.004108723 0.1577381


## [99,] 0.01800000 0.003476612 0.1547619

## [100,] 0.01800000 0.003476612 0.1547619

## [101,] 0.01800000 0.003160556 0.1577381

## [102,] 0.01771429 0.002844501 0.1577381

## [103,] 0.01857143 0.003476612 0.1607143

## [104,] 0.01828571 0.003160556 0.1607143

## [105,] 0.01828571 0.003160556 0.1607143

## [106,] 0.01885714 0.003476612 0.1636905

## [107,] 0.01914286 0.003792668 0.1636905

## [108,] 0.01828571 0.003476612 0.1577381

## [109,] 0.01828571 0.003476612 0.1577381

## [110,] 0.01857143 0.003160556 0.1636905

## [111,] 0.01857143 0.003476612 0.1607143

## [112,] 0.01857143 0.003476612 0.1607143

## [113,] 0.01742857 0.002844501 0.1547619

## [114,] 0.01800000 0.003160556 0.1577381

## [115,] 0.01828571 0.002844501 0.1636905

## [116,] 0.01800000 0.002528445 0.1636905

## [117,] 0.01828571 0.003476612 0.1577381

## [118,] 0.01800000 0.002844501 0.1607143

## [119,] 0.01800000 0.002844501 0.1607143

## [120,] 0.01800000 0.003160556 0.1577381

## [121,] 0.01857143 0.003476612 0.1607143

## [122,] 0.01857143 0.003476612 0.1607143

## [123,] 0.01914286 0.003792668 0.1636905

## [124,] 0.01828571 0.003160556 0.1607143

## [125,] 0.01800000 0.002844501 0.1607143


## [126,] 0.01885714 0.003160556 0.1666667

## [127,] 0.01857143 0.003160556 0.1636905

## [128,] 0.01857143 0.003476612 0.1607143

## [129,] 0.01828571 0.003476612 0.1577381

## [130,] 0.01800000 0.003160556 0.1577381

## [131,] 0.01800000 0.002844501 0.1607143

## [132,] 0.01885714 0.003160556 0.1666667

## [133,] 0.01828571 0.003160556 0.1607143

## [134,] 0.01885714 0.003160556 0.1666667

## [135,] 0.01857143 0.003160556 0.1636905

## [136,] 0.01885714 0.003160556 0.1666667

## [137,] 0.01828571 0.003476612 0.1577381

## [138,] 0.01857143 0.003476612 0.1607143

## [139,] 0.01857143 0.003160556 0.1636905

## [140,] 0.01885714 0.003476612 0.1636905

## [141,] 0.01885714 0.003476612 0.1636905

## [142,] 0.01857143 0.003476612 0.1607143

## [143,] 0.01914286 0.003476612 0.1666667

## [144,] 0.01828571 0.002844501 0.1636905

## [145,] 0.01885714 0.003160556 0.1666667

## [146,] 0.01857143 0.003160556 0.1636905

## [147,] 0.01885714 0.003160556 0.1666667

## [148,] 0.01857143 0.002844501 0.1666667

## [149,] 0.01857143 0.002844501 0.1666667

## [150,] 0.01857143 0.002844501 0.1666667

## [151,] 0.01857143 0.002844501 0.1666667

## [152,] 0.01942857 0.003160556 0.1726190

## [153,] 0.01942857 0.003160556 0.1726190

## [154,] 0.01857143 0.003160556 0.1636905


## [155,] 0.01914286 0.003476612 0.1666667

## [156,] 0.01857143 0.003160556 0.1636905

## [157,] 0.01914286 0.003160556 0.1696429

## [158,] 0.01914286 0.003160556 0.1696429

## [159,] 0.01885714 0.003160556 0.1666667

## [160,] 0.01885714 0.003476612 0.1636905

## [161,] 0.01857143 0.003160556 0.1636905

## [162,] 0.01914286 0.003160556 0.1696429

## [163,] 0.01885714 0.002844501 0.1696429

## [164,] 0.01828571 0.002844501 0.1636905

## [165,] 0.01857143 0.002844501 0.1666667

## [166,] 0.01857143 0.002844501 0.1666667

## [167,] 0.01771429 0.002528445 0.1607143

## [168,] 0.01828571 0.002844501 0.1636905

## [169,] 0.01857143 0.003160556 0.1636905

## [170,] 0.01771429 0.002528445 0.1607143

## [171,] 0.01800000 0.003160556 0.1577381

## [172,] 0.01857143 0.003160556 0.1636905

## [173,] 0.01857143 0.003160556 0.1636905

## [174,] 0.01800000 0.003160556 0.1577381

## [175,] 0.01828571 0.003160556 0.1607143

## [176,] 0.01828571 0.003160556 0.1607143

## [177,] 0.01857143 0.003476612 0.1607143

## [178,] 0.01771429 0.003160556 0.1547619

## [179,] 0.01800000 0.003476612 0.1547619

## [180,] 0.01828571 0.003476612 0.1577381

## [181,] 0.01800000 0.003476612 0.1547619


## [182,] 0.01800000 0.003476612 0.1547619

## [183,] 0.01771429 0.003476612 0.1517857

## [184,] 0.01828571 0.003160556 0.1607143

## [185,] 0.01828571 0.003476612 0.1577381

## [186,] 0.01800000 0.003160556 0.1577381

## [187,] 0.01742857 0.003160556 0.1517857

## [188,] 0.01800000 0.003160556 0.1577381

## [189,] 0.01742857 0.003160556 0.1517857

## [190,] 0.01857143 0.003476612 0.1607143

## [191,] 0.01800000 0.003160556 0.1577381

## [192,] 0.01857143 0.003476612 0.1607143

## [193,] 0.01857143 0.003160556 0.1636905

## [194,] 0.01800000 0.003160556 0.1577381

## [195,] 0.01828571 0.003160556 0.1607143

## [196,] 0.01800000 0.003160556 0.1577381

## [197,] 0.01771429 0.003160556 0.1547619

## [198,] 0.01800000 0.003160556 0.1577381

## [199,] 0.01828571 0.003160556 0.1607143

## [200,] 0.01771429 0.003160556 0.1547619

## [201,] 0.01828571 0.003160556 0.1607143

## [202,] 0.01828571 0.003160556 0.1607143

## [203,] 0.01800000 0.003160556 0.1577381

## [204,] 0.01828571 0.003160556 0.1607143

## [205,] 0.01800000 0.003160556 0.1577381

## [206,] 0.01800000 0.002844501 0.1607143

## [207,] 0.01771429 0.002844501 0.1577381

## [208,] 0.01771429 0.002844501 0.1577381

## [209,] 0.01800000 0.002528445 0.1636905

## [210,] 0.01828571 0.002844501 0.1636905


## [211,] 0.01828571 0.002528445 0.1666667

## [212,] 0.01800000 0.002528445 0.1636905

## [213,] 0.01800000 0.002528445 0.1636905

## [214,] 0.01771429 0.001896334 0.1666667

## [215,] 0.01800000 0.002212389 0.1666667

## [216,] 0.01857143 0.002528445 0.1696429

## [217,] 0.01885714 0.002844501 0.1696429

## [218,] 0.01857143 0.002844501 0.1666667

## [219,] 0.01857143 0.002844501 0.1666667

## [220,] 0.01828571 0.002844501 0.1636905

## [221,] 0.01857143 0.002844501 0.1666667

## [222,] 0.01857143 0.002844501 0.1666667

## [223,] 0.01828571 0.002528445 0.1666667

## [224,] 0.01800000 0.002528445 0.1636905

## [225,] 0.01771429 0.002528445 0.1607143

## [226,] 0.01771429 0.002528445 0.1607143

## [227,] 0.01742857 0.002212389 0.1607143

## [228,] 0.01742857 0.002212389 0.1607143

## [229,] 0.01714286 0.002212389 0.1577381

## [230,] 0.01714286 0.002528445 0.1547619

## [231,] 0.01685714 0.002212389 0.1547619

## [232,] 0.01685714 0.002212389 0.1547619

## [233,] 0.01742857 0.002528445 0.1577381

## [234,] 0.01685714 0.002212389 0.1547619

## [235,] 0.01742857 0.002528445 0.1577381

## [236,] 0.01714286 0.002528445 0.1547619

## [237,] 0.01771429 0.002844501 0.1577381


## [238,] 0.01771429 0.002528445 0.1607143

## [239,] 0.01685714 0.002528445 0.1517857

## [240,] 0.01714286 0.002528445 0.1547619

## [241,] 0.01714286 0.002528445 0.1547619

## [242,] 0.01828571 0.002844501 0.1636905

## [243,] 0.01800000 0.002844501 0.1607143

## [244,] 0.01828571 0.002844501 0.1636905

## [245,] 0.01828571 0.002844501 0.1636905

## [246,] 0.01800000 0.002528445 0.1636905

## [247,] 0.01800000 0.002528445 0.1636905

## [248,] 0.01800000 0.002528445 0.1636905

## [249,] 0.01800000 0.002528445 0.1636905

## [250,] 0.01828571 0.002844501 0.1636905

## [251,] 0.01828571 0.002844501 0.1636905

## [252,] 0.01828571 0.002844501 0.1636905

## [253,] 0.01828571 0.002844501 0.1636905

## [254,] 0.01828571 0.002844501 0.1636905

## [255,] 0.01857143 0.002844501 0.1666667

## [256,] 0.01800000 0.002844501 0.1607143

## [257,] 0.01800000 0.002844501 0.1607143

## [258,] 0.01800000 0.002844501 0.1607143

## [259,] 0.01800000 0.002844501 0.1607143

## [260,] 0.01828571 0.002844501 0.1636905

## [261,] 0.01771429 0.002844501 0.1577381

## [262,] 0.01800000 0.002844501 0.1607143

## [263,] 0.01828571 0.002844501 0.1636905

## [264,] 0.01828571 0.002844501 0.1636905

## [265,] 0.01800000 0.002844501 0.1607143

## [266,] 0.01800000 0.002844501 0.1607143


## [267,] 0.01800000 0.002844501 0.1607143

## [268,] 0.01857143 0.002844501 0.1666667

## [269,] 0.01800000 0.002844501 0.1607143

## [270,] 0.01800000 0.002844501 0.1607143

## [271,] 0.01828571 0.002844501 0.1636905

## [272,] 0.01800000 0.002844501 0.1607143

## [273,] 0.01771429 0.002844501 0.1577381

## [274,] 0.01800000 0.002844501 0.1607143

## [275,] 0.01800000 0.002844501 0.1607143

## [276,] 0.01771429 0.002844501 0.1577381

## [277,] 0.01771429 0.002844501 0.1577381

## [278,] 0.01771429 0.002844501 0.1577381

## [279,] 0.01714286 0.002844501 0.1517857

## [280,] 0.01771429 0.002844501 0.1577381

## [281,] 0.01742857 0.002844501 0.1547619

## [282,] 0.01771429 0.003160556 0.1547619

## [283,] 0.01771429 0.003160556 0.1547619

## [284,] 0.01742857 0.003160556 0.1517857

## [285,] 0.01771429 0.003160556 0.1547619

## [286,] 0.01828571 0.003160556 0.1607143

## [287,] 0.01800000 0.002844501 0.1607143

## [288,] 0.01771429 0.002844501 0.1577381

## [289,] 0.01714286 0.002528445 0.1547619

## [290,] 0.01685714 0.002528445 0.1517857

## [291,] 0.01714286 0.002528445 0.1547619

## [292,] 0.01714286 0.002528445 0.1547619

## [293,] 0.01742857 0.002528445 0.1577381


## [294,] 0.01771429 0.002844501 0.1577381

## [295,] 0.01771429 0.002844501 0.1577381

## [296,] 0.01771429 0.002844501 0.1577381

## [297,] 0.01742857 0.002528445 0.1577381

## [298,] 0.01742857 0.002528445 0.1577381

## [299,] 0.01742857 0.002528445 0.1577381

## [300,] 0.01771429 0.002528445 0.1607143

## [301,] 0.01771429 0.002528445 0.1607143

## [302,] 0.01771429 0.002528445 0.1607143

## [303,] 0.01742857 0.002528445 0.1577381

## [304,] 0.01742857 0.002212389 0.1607143

## [305,] 0.01771429 0.002844501 0.1577381

## [306,] 0.01714286 0.002528445 0.1547619

## [307,] 0.01742857 0.002528445 0.1577381

## [308,] 0.01714286 0.002528445 0.1547619

## [309,] 0.01714286 0.002528445 0.1547619

## [310,] 0.01714286 0.002528445 0.1547619

## [311,] 0.01742857 0.002528445 0.1577381

## [312,] 0.01742857 0.002528445 0.1577381

## [313,] 0.01742857 0.002528445 0.1577381

## [314,] 0.01714286 0.002528445 0.1547619

## [315,] 0.01714286 0.002528445 0.1547619

## [316,] 0.01714286 0.002528445 0.1547619

## [317,] 0.01714286 0.002528445 0.1547619

## [318,] 0.01714286 0.002528445 0.1547619

## [319,] 0.01742857 0.002528445 0.1577381

## [320,] 0.01742857 0.002528445 0.1577381


## [321,] 0.01714286 0.002212389 0.1577381

## [322,] 0.01685714 0.002212389 0.1547619

## [323,] 0.01714286 0.002212389 0.1577381

## [324,] 0.01742857 0.002528445 0.1577381

## [325,] 0.01714286 0.002528445 0.1547619

## [326,] 0.01657143 0.002212389 0.1517857

## [327,] 0.01657143 0.002212389 0.1517857

## [328,] 0.01685714 0.002212389 0.1547619

## [329,] 0.01685714 0.002212389 0.1547619

## [330,] 0.01657143 0.002212389 0.1517857

## [331,] 0.01657143 0.002212389 0.1517857

## [332,] 0.01685714 0.002528445 0.1517857

## [333,] 0.01685714 0.002528445 0.1517857

## [334,] 0.01685714 0.002528445 0.1517857

## [335,] 0.01714286 0.002844501 0.1517857

## [336,] 0.01685714 0.002528445 0.1517857

## [337,] 0.01685714 0.002528445 0.1517857

## [338,] 0.01685714 0.002528445 0.1517857

## [339,] 0.01685714 0.002528445 0.1517857

## [340,] 0.01685714 0.002528445 0.1517857

## [341,] 0.01714286 0.002844501 0.1517857

## [342,] 0.01685714 0.002528445 0.1517857

## [343,] 0.01685714 0.002528445 0.1517857

## [344,] 0.01685714 0.002528445 0.1517857

## [345,] 0.01685714 0.002528445 0.1517857

## [346,] 0.01714286 0.002528445 0.1547619

## [347,] 0.01714286 0.002528445 0.1547619

## [348,] 0.01742857 0.002844501 0.1547619

## [349,] 0.01742857 0.002844501 0.1547619


## [350,] 0.01742857 0.002844501 0.1547619

## [351,] 0.01771429 0.002844501 0.1577381

## [352,] 0.01742857 0.002844501 0.1547619

## [353,] 0.01800000 0.002844501 0.1607143

## [354,] 0.01742857 0.002528445 0.1577381

## [355,] 0.01771429 0.002844501 0.1577381

## [356,] 0.01742857 0.002528445 0.1577381

## [357,] 0.01742857 0.002528445 0.1577381

## [358,] 0.01800000 0.002844501 0.1607143

## [359,] 0.01771429 0.002528445 0.1607143

## [360,] 0.01771429 0.002844501 0.1577381

## [361,] 0.01800000 0.003160556 0.1577381

## [362,] 0.01800000 0.003160556 0.1577381

## [363,] 0.01771429 0.002844501 0.1577381

## [364,] 0.01800000 0.002844501 0.1607143

## [365,] 0.01800000 0.002844501 0.1607143

## [366,] 0.01800000 0.002844501 0.1607143

## [367,] 0.01771429 0.002844501 0.1577381

## [368,] 0.01771429 0.002844501 0.1577381

## [369,] 0.01771429 0.002844501 0.1577381

## [370,] 0.01771429 0.002844501 0.1577381

## [371,] 0.01771429 0.002844501 0.1577381

## [372,] 0.01771429 0.002844501 0.1577381

## [373,] 0.01771429 0.002844501 0.1577381

## [374,] 0.01771429 0.002844501 0.1577381

## [375,] 0.01771429 0.002844501 0.1577381

## [376,] 0.01771429 0.002844501 0.1577381


## [377,] 0.01800000 0.002844501 0.1607143

## [378,] 0.01771429 0.002844501 0.1577381

## [379,] 0.01771429 0.002844501 0.1577381

## [380,] 0.01771429 0.002844501 0.1577381

## [381,] 0.01771429 0.002844501 0.1577381

## [382,] 0.01771429 0.002844501 0.1577381

## [383,] 0.01771429 0.002844501 0.1577381

## [384,] 0.01771429 0.002844501 0.1577381

## [385,] 0.01771429 0.002844501 0.1577381

## [386,] 0.01771429 0.002844501 0.1577381

## [387,] 0.01742857 0.002844501 0.1547619

## [388,] 0.01771429 0.002844501 0.1577381

## [389,] 0.01714286 0.002528445 0.1547619

## [390,] 0.01714286 0.002528445 0.1547619

## [391,] 0.01800000 0.002844501 0.1607143

## [392,] 0.01742857 0.002844501 0.1547619

## [393,] 0.01800000 0.002844501 0.1607143

## [394,] 0.01771429 0.002844501 0.1577381

## [395,] 0.01742857 0.002844501 0.1547619

## [396,] 0.01771429 0.002844501 0.1577381

## [397,] 0.01742857 0.002844501 0.1547619

## [398,] 0.01742857 0.002844501 0.1547619

## [399,] 0.01742857 0.002844501 0.1547619

## [400,] 0.01742857 0.002844501 0.1547619

## [401,] 0.01742857 0.002844501 0.1547619

## [402,] 0.01742857 0.002844501 0.1547619

## [403,] 0.01742857 0.002844501 0.1547619

## [404,] 0.01742857 0.002844501 0.1547619

## [405,] 0.01771429 0.002844501 0.1577381


## [406,] 0.01742857 0.002844501 0.1547619

## [407,] 0.01771429 0.002844501 0.1577381

## [408,] 0.01742857 0.002844501 0.1547619

## [409,] 0.01714286 0.002844501 0.1517857

## [410,] 0.01742857 0.002844501 0.1547619

## [411,] 0.01742857 0.002844501 0.1547619

## [412,] 0.01714286 0.002844501 0.1517857

## [413,] 0.01742857 0.002844501 0.1547619

## [414,] 0.01742857 0.002844501 0.1547619

## [415,] 0.01742857 0.002844501 0.1547619

## [416,] 0.01742857 0.002844501 0.1547619

## [417,] 0.01742857 0.002844501 0.1547619

## [418,] 0.01742857 0.002844501 0.1547619

## [419,] 0.01771429 0.002844501 0.1577381

## [420,] 0.01771429 0.002844501 0.1577381

## [421,] 0.01742857 0.002844501 0.1547619

## [422,] 0.01742857 0.002844501 0.1547619

## [423,] 0.01742857 0.002844501 0.1547619

## [424,] 0.01742857 0.002844501 0.1547619

## [425,] 0.01771429 0.003160556 0.1547619

## [426,] 0.01742857 0.002844501 0.1547619

## [427,] 0.01742857 0.002844501 0.1547619

## [428,] 0.01771429 0.002844501 0.1577381

## [429,] 0.01742857 0.002844501 0.1547619

## [430,] 0.01771429 0.002844501 0.1577381

## [431,] 0.01771429 0.002844501 0.1577381

## [432,] 0.01800000 0.003160556 0.1577381


## [433,] 0.01800000 0.003160556 0.1577381

## [434,] 0.01742857 0.002844501 0.1547619

## [435,] 0.01771429 0.003160556 0.1547619

## [436,] 0.01771429 0.003160556 0.1547619

## [437,] 0.01771429 0.003160556 0.1547619

## [438,] 0.01742857 0.002844501 0.1547619

## [439,] 0.01742857 0.002844501 0.1547619

## [440,] 0.01742857 0.002844501 0.1547619

## [441,] 0.01742857 0.002844501 0.1547619

## [442,] 0.01742857 0.002844501 0.1547619

## [443,] 0.01771429 0.003160556 0.1547619

## [444,] 0.01771429 0.003160556 0.1547619

## [445,] 0.01742857 0.002844501 0.1547619

## [446,] 0.01742857 0.002844501 0.1547619

## [447,] 0.01742857 0.002844501 0.1547619

## [448,] 0.01742857 0.002844501 0.1547619

## [449,] 0.01714286 0.002844501 0.1517857

## [450,] 0.01714286 0.002844501 0.1517857

## [451,] 0.01714286 0.002844501 0.1517857

## [452,] 0.01771429 0.002844501 0.1577381

## [453,] 0.01771429 0.002844501 0.1577381

## [454,] 0.01771429 0.002844501 0.1577381

## [455,] 0.01771429 0.002844501 0.1577381

## [456,] 0.01771429 0.002844501 0.1577381

## [457,] 0.01771429 0.002844501 0.1577381

## [458,] 0.01771429 0.002844501 0.1577381

## [459,] 0.01771429 0.002844501 0.1577381

## [460,] 0.01771429 0.002844501 0.1577381

## [461,] 0.01771429 0.002844501 0.1577381


## [462,] 0.01771429 0.002844501 0.1577381

## [463,] 0.01742857 0.002844501 0.1547619

## [464,] 0.01742857 0.002844501 0.1547619

## [465,] 0.01742857 0.002844501 0.1547619

## [466,] 0.01742857 0.002844501 0.1547619

## [467,] 0.01742857 0.002844501 0.1547619

## [468,] 0.01742857 0.002844501 0.1547619

## [469,] 0.01742857 0.002844501 0.1547619

## [470,] 0.01742857 0.002844501 0.1547619

## [471,] 0.01742857 0.002844501 0.1547619

## [472,] 0.01742857 0.002844501 0.1547619

## [473,] 0.01742857 0.002844501 0.1547619

## [474,] 0.01742857 0.002844501 0.1547619

## [475,] 0.01742857 0.002844501 0.1547619

## [476,] 0.01742857 0.002844501 0.1547619

## [477,] 0.01742857 0.002844501 0.1547619

## [478,] 0.01742857 0.002844501 0.1547619

## [479,] 0.01742857 0.002844501 0.1547619

## [480,] 0.01742857 0.002844501 0.1547619

## [481,] 0.01742857 0.002844501 0.1547619

## [482,] 0.01742857 0.002844501 0.1547619

## [483,] 0.01742857 0.002844501 0.1547619

## [484,] 0.01742857 0.002844501 0.1547619

## [485,] 0.01742857 0.002844501 0.1547619

## [486,] 0.01742857 0.002844501 0.1547619

## [487,] 0.01771429 0.003160556 0.1547619

## [488,] 0.01800000 0.003160556 0.1577381


## [489,] 0.01742857 0.002844501 0.1547619

## [490,] 0.01800000 0.003160556 0.1577381

## [491,] 0.01800000 0.003160556 0.1577381

## [492,] 0.01742857 0.002844501 0.1547619

## [493,] 0.01742857 0.002844501 0.1547619

## [494,] 0.01771429 0.002844501 0.1577381

## [495,] 0.01800000 0.003160556 0.1577381

## [496,] 0.01771429 0.002844501 0.1577381

## [497,] 0.01800000 0.003160556 0.1577381

## [498,] 0.01800000 0.003160556 0.1577381

## [499,] 0.01771429 0.003160556 0.1547619

## [500,] 0.01771429 0.002844501 0.1577381

## [501,] 0.01742857 0.002844501 0.1547619

## [502,] 0.01800000 0.003160556 0.1577381

## [503,] 0.01771429 0.002844501 0.1577381

## [504,] 0.01771429 0.002844501 0.1577381

## [505,] 0.01771429 0.002844501 0.1577381

## [506,] 0.01771429 0.002844501 0.1577381

## [507,] 0.01771429 0.002844501 0.1577381

## [508,] 0.01771429 0.002844501 0.1577381

## [509,] 0.01771429 0.002844501 0.1577381

## [510,] 0.01771429 0.002844501 0.1577381

## [511,] 0.01771429 0.002844501 0.1577381

## [512,] 0.01771429 0.002844501 0.1577381

## [513,] 0.01771429 0.002844501 0.1577381

## [514,] 0.01771429 0.002844501 0.1577381

## [515,] 0.01771429 0.002844501 0.1577381

## [516,] 0.01742857 0.002844501 0.1547619

## [517,] 0.01771429 0.002844501 0.1577381


## [518,] 0.01800000 0.003160556 0.1577381

## [519,] 0.01800000 0.003160556 0.1577381

## [520,] 0.01800000 0.003160556 0.1577381

## [521,] 0.01828571 0.003160556 0.1607143

## [522,] 0.01771429 0.003160556 0.1547619

## [523,] 0.01771429 0.003160556 0.1547619

## [524,] 0.01800000 0.003160556 0.1577381

## [525,] 0.01800000 0.003160556 0.1577381

## [526,] 0.01800000 0.003160556 0.1577381

## [527,] 0.01771429 0.003160556 0.1547619

## [528,] 0.01771429 0.003160556 0.1547619

## [529,] 0.01742857 0.002844501 0.1547619

## [530,] 0.01742857 0.002844501 0.1547619

## [531,] 0.01742857 0.002844501 0.1547619

## [532,] 0.01742857 0.002844501 0.1547619

## [533,] 0.01742857 0.002844501 0.1547619

## [534,] 0.01771429 0.003160556 0.1547619

## [535,] 0.01771429 0.003160556 0.1547619

## [536,] 0.01771429 0.003160556 0.1547619

## [537,] 0.01771429 0.003160556 0.1547619

## [538,] 0.01771429 0.003160556 0.1547619

## [539,] 0.01771429 0.003160556 0.1547619

## [540,] 0.01771429 0.003160556 0.1547619

## [541,] 0.01771429 0.003160556 0.1547619

## [542,] 0.01771429 0.003160556 0.1547619

## [543,] 0.01771429 0.003160556 0.1547619

## [544,] 0.01771429 0.003160556 0.1547619


## [545,] 0.01714286 0.002528445 0.1547619

## [546,] 0.01742857 0.002844501 0.1547619

## [547,] 0.01742857 0.002844501 0.1547619

## [548,] 0.01742857 0.002844501 0.1547619

## [549,] 0.01742857 0.002844501 0.1547619

## [550,] 0.01771429 0.003160556 0.1547619

## [551,] 0.01742857 0.002844501 0.1547619

## [552,] 0.01771429 0.003160556 0.1547619

## [553,] 0.01771429 0.003160556 0.1547619

## [554,] 0.01742857 0.002844501 0.1547619

## [555,] 0.01742857 0.002844501 0.1547619

## [556,] 0.01771429 0.002844501 0.1577381

## [557,] 0.01742857 0.002844501 0.1547619

## [558,] 0.01742857 0.002844501 0.1547619

## [559,] 0.01771429 0.003160556 0.1547619

## [560,] 0.01771429 0.003160556 0.1547619

## [561,] 0.01771429 0.003160556 0.1547619

## [562,] 0.01771429 0.003160556 0.1547619

## [563,] 0.01771429 0.003160556 0.1547619

## [564,] 0.01771429 0.003160556 0.1547619

## [565,] 0.01771429 0.003160556 0.1547619

## [566,] 0.01742857 0.002844501 0.1547619

## [567,] 0.01742857 0.002844501 0.1547619

## [568,] 0.01771429 0.003160556 0.1547619

## [569,] 0.01742857 0.002844501 0.1547619

## [570,] 0.01771429 0.003160556 0.1547619

## [571,] 0.01771429 0.003160556 0.1547619


## [572,] 0.01742857 0.002844501 0.1547619

## [573,] 0.01742857 0.002844501 0.1547619

## [574,] 0.01742857 0.002844501 0.1547619

## [575,] 0.01742857 0.002844501 0.1547619

## [576,] 0.01742857 0.002844501 0.1547619

## [577,] 0.01742857 0.002844501 0.1547619

## [578,] 0.01714286 0.002528445 0.1547619

## [579,] 0.01742857 0.002844501 0.1547619

## [580,] 0.01742857 0.002844501 0.1547619

## [581,] 0.01714286 0.002528445 0.1547619

## [582,] 0.01714286 0.002528445 0.1547619

## [583,] 0.01714286 0.002528445 0.1547619

## [584,] 0.01714286 0.002528445 0.1547619

## [585,] 0.01685714 0.002528445 0.1517857

## [586,] 0.01685714 0.002528445 0.1517857

## [587,] 0.01685714 0.002528445 0.1517857

## [588,] 0.01685714 0.002528445 0.1517857

## [589,] 0.01685714 0.002528445 0.1517857

## [590,] 0.01714286 0.002844501 0.1517857

## [591,] 0.01714286 0.002844501 0.1517857

## [592,] 0.01685714 0.002528445 0.1517857

## [593,] 0.01685714 0.002528445 0.1517857

## [594,] 0.01685714 0.002528445 0.1517857

## [595,] 0.01685714 0.002528445 0.1517857

## [596,] 0.01714286 0.002528445 0.1547619

## [597,] 0.01714286 0.002528445 0.1547619

## [598,] 0.01685714 0.002528445 0.1517857

## [599,] 0.01685714 0.002528445 0.1517857

## [600,] 0.01714286 0.002528445 0.1547619


## 0 1 MeanDecreaseAccuracy

## Age 11.1647166 -0.0858323 10.646321

## Experience 3.5523053 -2.2981929 2.792322

## Income 180.2461047 113.8246739 196.790615

## ZipCode -0.8192121 -1.3525852 -1.499848

## FamilySize 91.4176325 51.8887573 91.224043

## CCAvg 20.4585091 21.0453064 23.817328

## Education 197.5912567 84.2465842 194.516093

## Mortgage 3.9342493 -5.4767495 1.772036

## SecuritiesAccountExist -0.2355867 -1.1312258 -1.426986

## DepositAccountExist 16.3522274 17.3611009 20.805963

## OnlineBankingExist 0.3744940 1.6913621 1.498142

## CreditCardExist 1.0010015 0.9885883 1.263890

## MeanDecreaseGini

## Age 2.96512204

## Experience 1.42467278

## Income 177.99835899

## ZipCode 0.59038829

## FamilySize 78.28873558

## CCAvg 43.85047345

## Education 194.60045363

## Mortgage 1.25291003

## SecuritiesAccountExist 0.09830039

## DepositAccountExist 14.85910450

## OnlineBankingExist 0.15240309

## CreditCardExist 0.06280318
##

## Call:

## randomForest(formula = trainDSRF$AcceptLoanOffer ~ ., data = trainDSRF, ntree = 191, mtry =


9, nodesize = 70, importance = TRUE)

## Type of random forest: classification ## Number of trees: 191

## No. of variables tried at each split: 9 ##

## OOB estimate of error rate: 1.37% ## Confusion matrix:

## 0 1 class.error

## 0 3160 4 0.001264223

## 1 44 292 0.130952381

## 0 1 MeanDecreaseAccuracy MeanDecreaseGini

## Income 107.72 83.70 131.82 179.33

## Education 109.18 51.15 109.08 194.34

## FamilySize 61.29 32.94 60.83 81.01

## CCAvg 13.84 13.82 16.82 36.99

## DepositAccountExist 8.09 10.23 12.03 17.90

## Age 8.69 1.32 8.52 3.76

## SecuritiesAccountExist 1.42 1.00 1.18 0.02

## Experience 1.67 -1.18 1.12 1.01

## CreditCardExist 1.00 -0.02 1.06 0.12

## ZipCode -0.24 0.96 0.67 0.62

## Mortgage 2.08 -3.99 0.50 1.41

## OnlineBankingExist 0.00 0.00 0.00 0.08

## # A tibble: 6 x 15

## Age Experience Income ZipCode FamilySize CCAvg Education Mortgage

## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>

## 1 25 1 49 91107 4 1.6 1 0
## 2 39 15 11 94720 1 1 1 0

## 3 35 9 100 94112 1 2.7 2 0

## 4 35 8 45 91330 4 1 2 0

## 5 37 13 29 92121 4 0.4 2 155

## 6 50 24 22 93943 1 0.3 3 0

## # ... with 8 more variables: AcceptLoanOffer <fct>,

## # SecuritiesAccountExist <dbl>, DepositAccountExist <dbl>,

## # OnlineBankingExist <dbl>, CreditCardExist <dbl>, prediction <fct>, ## # score[,"0"] <dbl>, [,"1"]


<dbl>

## # A tibble: 6 x 16

## Age Experience Income ZipCode FamilySize CCAvg Education Mortgage ## <dbl>


<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>

## 1 25 1 49 91107 4 1.6 1 0

## 2 39 15 11 94720 1 1 1 0

## 3 35 9 100 94112 1 2.7 2 0

## 4 35 8 45 91330 4 1 2 0

## 5 37 13 29 92121 4 0.4 2 155

## 6 50 24 22 93943 1 0.3 3 0

## # ... with 9 more variables: AcceptLoanOffer <fct>,

## # SecuritiesAccountExist <dbl>, DepositAccountExist <dbl>,

## # OnlineBankingExist <dbl>, CreditCardExist <dbl>, prediction <fct>, ## # score[,"0"] <dbl>, [,"1"]


<dbl>, deciles <dbl>

## deciles cnt cnt_resp cnt_non_resp ## 1: 10 350 305 45

## 2: 9 3150 31 3119

## [1] "Lift: 9.06" "Lift: 1.04"

## Detection Rate : 0.08343

## Detection Prevalence : 0.08457

##
## ## Balanced Accuracy :

'Positive' Class :0.93389

##

## [1] 1500 15

## # A tibble: 6 x 16

## Age Experience Income ZipCode FamilySize CCAvg Education Mortgage ## <dbl>


<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>

## 1 45 19 34 90089 3 1.5 1 0

## 2 53 27 72 91711 2 1.5 2 0

## 3 34 9 180 93023 1 8.9 3 0

## 4 48 23 114 93106 2 3.8 3 0

## 5 67 41 112 91741 1 2 1 0

## 6 60 30 22 95054 1 1.5 3 0