rm(list=ls())
set.seed(123)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.5.2 ✔ tibble 3.3.0
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
## ✔ purrr 1.0.4
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
#credit <- read.csv("C:/Users/cu_dv/Downloads/german.data.csv")
credit <- read.table("~/GT HW/statlog_german_credit_data/german.data", sep = " ")
##View(credit)
str(credit)
## 'data.frame': 1000 obs. of 21 variables:
## $ V1 : chr "A11" "A12" "A14" "A11" ...
## $ V2 : int 6 48 12 42 24 36 24 36 12 30 ...
## $ V3 : chr "A34" "A32" "A34" "A32" ...
## $ V4 : chr "A43" "A43" "A46" "A42" ...
## $ V5 : int 1169 5951 2096 7882 4870 9055 2835 6948 3059 5234 ...
## $ V6 : chr "A65" "A61" "A61" "A61" ...
## $ V7 : chr "A75" "A73" "A74" "A74" ...
## $ V8 : int 4 2 2 2 3 2 3 2 2 4 ...
## $ V9 : chr "A93" "A92" "A93" "A93" ...
## $ V10: chr "A101" "A101" "A101" "A103" ...
## $ V11: int 4 2 3 4 4 4 4 2 4 2 ...
## $ V12: chr "A121" "A121" "A121" "A122" ...
## $ V13: int 67 22 49 45 53 35 53 35 61 28 ...
## $ V14: chr "A143" "A143" "A143" "A143" ...
## $ V15: chr "A152" "A152" "A152" "A153" ...
## $ V16: int 2 1 1 1 2 1 1 1 1 2 ...
## $ V17: chr "A173" "A173" "A172" "A173" ...
## $ V18: int 1 1 2 2 2 2 1 1 1 1 ...
## $ V19: chr "A192" "A191" "A191" "A191" ...
## $ V20: chr "A201" "A201" "A201" "A201" ...
## $ V21: int 1 2 1 1 2 1 1 1 1 2 ...
## Variable name
mynames <- c("checking_balance","months_loan_duration", "credit_history", "purpose", "credit_amount", "savings_balance",
"employment_duration",
"percent_of_income",
"status_sex",
"debtors_guarantors",
"years_at_residence",
"property",
"age",
"other_credit",
"housing",
"existing_loans_count",
"job",
"dependents",
"phone",
"foreign worker",
"default"
)
# mynames <- paste0("Attribute", 1:20)
# mynames <- c( mynames, "class")
names(credit) <- mynames
glimpse(credit)
## Rows: 1,000
## Columns: 21
## $ checking_balance <chr> "A11", "A12", "A14", "A11", "A11", "A14", "A14", …
## $ months_loan_duration <int> 6, 48, 12, 42, 24, 36, 24, 36, 12, 30, 12, 48, 12…
## $ credit_history <chr> "A34", "A32", "A34", "A32", "A33", "A32", "A32", …
## $ purpose <chr> "A43", "A43", "A46", "A42", "A40", "A46", "A42", …
## $ credit_amount <int> 1169, 5951, 2096, 7882, 4870, 9055, 2835, 6948, 3…
## $ savings_balance <chr> "A65", "A61", "A61", "A61", "A61", "A65", "A63", …
## $ employment_duration <chr> "A75", "A73", "A74", "A74", "A73", "A73", "A75", …
## $ percent_of_income <int> 4, 2, 2, 2, 3, 2, 3, 2, 2, 4, 3, 3, 1, 4, 2, 4, 4…
## $ status_sex <chr> "A93", "A92", "A93", "A93", "A93", "A93", "A93", …
## $ debtors_guarantors <chr> "A101", "A101", "A101", "A103", "A101", "A101", "…
## $ years_at_residence <int> 4, 2, 3, 4, 4, 4, 4, 2, 4, 2, 1, 4, 1, 4, 4, 2, 4…
## $ property <chr> "A121", "A121", "A121", "A122", "A124", "A124", "…
## $ age <int> 67, 22, 49, 45, 53, 35, 53, 35, 61, 28, 25, 24, 2…
## $ other_credit <chr> "A143", "A143", "A143", "A143", "A143", "A143", "…
## $ housing <chr> "A152", "A152", "A152", "A153", "A153", "A153", "…
## $ existing_loans_count <int> 2, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 2…
## $ job <chr> "A173", "A173", "A172", "A173", "A173", "A172", "…
## $ dependents <int> 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
## $ phone <chr> "A192", "A191", "A191", "A191", "A191", "A192", "…
## $ `foreign worker` <chr> "A201", "A201", "A201", "A201", "A201", "A201", "…
## $ default <int> 1, 2, 1, 1, 2, 1, 1, 1, 1, 2, 2, 2, 1, 2, 1, 2, 1…
##summary(credit)
credit$checking_balance <- factor(credit$checking_balance)
credit$credit_history <- factor(credit$credit_history)
credit$purpose <- factor(credit$purpose)
credit$savings_balance <- factor(credit$savings_balance)
credit$employment_duration <- factor(credit$employment_duration)
credit$other_credit <- factor(credit$other_credit)
credit$housing <- factor(credit$housing)
credit$job <- factor(credit$job)
credit$phone <- factor(credit$phone)
##credit$default <- factor(credit$default)
##credit$phone<-factor(credit$phone,levels=c("A191","A192"),
## labels=c("no","yes"))
credit$default<-factor(credit$default,levels=c("1","2"),
labels=c("no","yes"))
credit <- credit[ ,-9]
credit <- credit[ , -9]
credit <- credit[ ,-10]
credit <- credit[ ,-17]
str(credit)
## 'data.frame': 1000 obs. of 17 variables:
## $ checking_balance : Factor w/ 4 levels "A11","A12","A13",..: 1 2 4 1 1 4 4 2 4 2 ...
## $ months_loan_duration: int 6 48 12 42 24 36 24 36 12 30 ...
## $ credit_history : Factor w/ 5 levels "A30","A31","A32",..: 5 3 5 3 4 3 3 3 3 5 ...
## $ purpose : Factor w/ 10 levels "A40","A41","A410",..: 5 5 8 4 1 8 4 2 5 1 ...
## $ credit_amount : int 1169 5951 2096 7882 4870 9055 2835 6948 3059 5234 ...
## $ savings_balance : Factor w/ 5 levels "A61","A62","A63",..: 5 1 1 1 1 5 3 1 4 1 ...
## $ employment_duration : Factor w/ 5 levels "A71","A72","A73",..: 5 3 4 4 3 3 5 3 4 1 ...
## $ percent_of_income : int 4 2 2 2 3 2 3 2 2 4 ...
## $ years_at_residence : int 4 2 3 4 4 4 4 2 4 2 ...
## $ age : int 67 22 49 45 53 35 53 35 61 28 ...
## $ other_credit : Factor w/ 3 levels "A141","A142",..: 3 3 3 3 3 3 3 3 3 3 ...
## $ housing : Factor w/ 3 levels "A151","A152",..: 2 2 2 3 3 3 2 1 2 2 ...
## $ existing_loans_count: int 2 1 1 1 2 1 1 1 1 2 ...
## $ job : Factor w/ 4 levels "A171","A172",..: 3 3 2 3 3 2 3 4 2 4 ...
## $ dependents : int 1 1 2 2 2 2 1 1 1 1 ...
## $ phone : Factor w/ 2 levels "A191","A192": 2 1 1 1 1 2 1 2 1 1 ...
## $ default : Factor w/ 2 levels "no","yes": 1 2 1 1 2 1 1 1 1 2 ...
table(credit$checking_balance)
##
## A11 A12 A13 A14
## 274 269 63 394
table(credit$savings_balance)
##
## A61 A62 A63 A64 A65
## 603 103 63 48 183
summary(credit$months_loan_duration)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 4.0 12.0 18.0 20.9 24.0 72.0
summary(credit$credit_amount)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 250 1366 2320 3271 3972 18424
table(credit$default)
##
## no yes
## 700 300
train_sample <- sample(1000, 900)
str(train_sample)
## int [1:900] 415 463 179 526 195 938 818 118 299 229 ...
credit_train <- credit[train_sample, ]
credit_test <- credit[-train_sample, ]
prop.table(table(credit_train$default))
##
## no yes
## 0.7055556 0.2944444
prop.table(table(credit_test$default))
##
## no yes
## 0.65 0.35
##install.packages("C50")
library(C50)
## Warning: package 'C50' was built under R version 4.5.1
credit_model <- C5.0(credit_train[-17], credit_train$default)
credit_model
##
## Call:
## C5.0.default(x = credit_train[-17], y = credit_train$default)
##
## Classification Tree
## Number of samples: 900
## Number of predictors: 16
##
## Tree size: 43
##
## Non-standard options: attempt to group attributes
summary(credit_model)
##
## Call:
## C5.0.default(x = credit_train[-17], y = credit_train$default)
##
##
## C5.0 [Release 2.07 GPL Edition] Sun Oct 19 18:16:22 2025
## -------------------------------
##
## Class specified by attribute `outcome'
##
## Read 900 cases (17 attributes) from undefined.data
##
## Decision tree:
##
## checking_balance in {A13,A14}: no (412/54)
## checking_balance in {A11,A12}:
## :...credit_history in {A30,A31}:
## :...housing = A151: yes (16/1)
## : housing = A153:
## : :...employment_duration in {A71,A72}: no (4/1)
## : : employment_duration in {A73,A74,A75}: yes (10)
## : housing = A152:
## : :...purpose in {A41,A42,A48,A49}: no (19/6)
## : purpose in {A410,A43,A44,A45,A46}: yes (6/1)
## : purpose = A40:
## : :...months_loan_duration <= 22: yes (6)
## : months_loan_duration > 22: no (2)
## credit_history in {A32,A33,A34}:
## :...months_loan_duration <= 15: no (180/45)
## months_loan_duration > 15:
## :...savings_balance in {A64,A65}:
## :...credit_history in {A33,A34}: no (14)
## : credit_history = A32:
## : :...purpose = A40: yes (7/1)
## : purpose in {A410,A44,A45,A46,A48,A49}: no (5)
## : purpose = A41:
## : :...credit_amount <= 6967: no (4)
## : : credit_amount > 6967: yes (2)
## : purpose = A42:
## : :...age <= 27: yes (2)
## : : age > 27: no (5)
## : purpose = A43:
## : :...credit_amount <= 6110: no (5)
## : credit_amount > 6110: yes (2)
## savings_balance in {A61,A62,A63}:
## :...months_loan_duration > 47: yes (23/3)
## months_loan_duration <= 47:
## :...employment_duration = A71:
## :...years_at_residence <= 2: yes (7)
## : years_at_residence > 2: no (12/2)
## employment_duration = A72:
## :...years_at_residence <= 1: no (16/6)
## : years_at_residence > 1:
## : :...job in {A171,A172,A174}: yes (11/1)
## : job = A173:
## : :...percent_of_income <= 2: no (4)
## : percent_of_income > 2: yes (12/1)
## employment_duration = A75:
## :...job = A173:
## : :...other_credit = A141: yes (6)
## : : other_credit in {A142,A143}: no (13/2)
## : job in {A171,A172}:
## : :...purpose in {A40,A49}: yes (2)
## : : purpose in {A41,A410,A42,A43,A44,A45,A46,
## : : A48}: no (5)
## : job = A174:
## : :...dependents > 1: no (3)
## : dependents <= 1:
## : :...age <= 37: no (3)
## : age > 37: yes (5)
## employment_duration = A73:
## :...housing = A153: yes (5)
## : housing in {A151,A152}:
## : :...percent_of_income > 3: yes (17/3)
## : percent_of_income <= 3:
## : :...credit_history = A33: no (3)
## : credit_history = A34: yes (5/2)
## : credit_history = A32:
## : :...phone = A191: yes (13/5)
## : phone = A192: no (6/1)
## employment_duration = A74:
## :...savings_balance in {A62,A63}: no (8)
## savings_balance = A61:
## :...job in {A171,A172,A174}: no (6)
## job = A173:
## :...dependents > 1: no (3/1)
## dependents <= 1:
## :...months_loan_duration <= 22: no (3)
## months_loan_duration > 22: yes (8)
##
##
## Evaluation on training data (900 cases):
##
## Decision Tree
## ----------------
## Size Errors
##
## 43 136(15.1%) <<
##
##
## (a) (b) <-classified as
## ---- ----
## 617 18 (a): class no
## 118 147 (b): class yes
##
##
## Attribute usage:
##
## 100.00% checking_balance
## 54.22% credit_history
## 48.11% months_loan_duration
## 27.22% savings_balance
## 21.11% employment_duration
## 12.44% housing
## 9.33% job
## 8.00% purpose
## 6.89% years_at_residence
## 6.67% percent_of_income
## 2.78% dependents
## 2.11% other_credit
## 2.11% phone
## 1.67% age
## 1.44% credit_amount
##
##
## Time: 0.0 secs
credit_pred <- predict(credit_model, credit_test)
#install.packages("gmodels")
library(gmodels)
## Warning: package 'gmodels' was built under R version 4.5.1
CrossTable(credit_test$default, credit_pred,
prop.chisq = FALSE, prop.c = FALSE, prop.r = FALSE,
dnn = c('actual default', 'predicted default'))
##
##
## Cell Contents
## |-------------------------|
## | N |
## | N / Table Total |
## |-------------------------|
##
##
## Total Observations in Table: 100
##
##
## | predicted default
## actual default | no | yes | Row Total |
## ---------------|-----------|-----------|-----------|
## no | 56 | 9 | 65 |
## | 0.560 | 0.090 | |
## ---------------|-----------|-----------|-----------|
## yes | 23 | 12 | 35 |
## | 0.230 | 0.120 | |
## ---------------|-----------|-----------|-----------|
## Column Total | 79 | 21 | 100 |
## ---------------|-----------|-----------|-----------|
##
##
credit_boost10 <- C5.0(credit_train[-17], credit_train$default,
trials = 10)
credit_boost10
##
## Call:
## C5.0.default(x = credit_train[-17], y = credit_train$default, trials = 10)
##
## Classification Tree
## Number of samples: 900
## Number of predictors: 16
##
## Number of boosting iterations: 10
## Average tree size: 38.2
##
## Non-standard options: attempt to group attributes
summary(credit_boost10)
##
## Call:
## C5.0.default(x = credit_train[-17], y = credit_train$default, trials = 10)
##
##
## C5.0 [Release 2.07 GPL Edition] Sun Oct 19 18:16:22 2025
## -------------------------------
##
## Class specified by attribute `outcome'
##
## Read 900 cases (17 attributes) from undefined.data
##
## ----- Trial 0: -----
##
## Decision tree:
##
## checking_balance in {A13,A14}: no (412/54)
## checking_balance in {A11,A12}:
## :...credit_history in {A30,A31}:
## :...housing = A151: yes (16/1)
## : housing = A153:
## : :...employment_duration in {A71,A72}: no (4/1)
## : : employment_duration in {A73,A74,A75}: yes (10)
## : housing = A152:
## : :...purpose in {A41,A42,A48,A49}: no (19/6)
## : purpose in {A410,A43,A44,A45,A46}: yes (6/1)
## : purpose = A40:
## : :...months_loan_duration <= 22: yes (6)
## : months_loan_duration > 22: no (2)
## credit_history in {A32,A33,A34}:
## :...months_loan_duration <= 15: no (180/45)
## months_loan_duration > 15:
## :...savings_balance in {A64,A65}:
## :...credit_history in {A33,A34}: no (14)
## : credit_history = A32:
## : :...purpose = A40: yes (7/1)
## : purpose in {A410,A44,A45,A46,A48,A49}: no (5)
## : purpose = A41:
## : :...credit_amount <= 6967: no (4)
## : : credit_amount > 6967: yes (2)
## : purpose = A42:
## : :...age <= 27: yes (2)
## : : age > 27: no (5)
## : purpose = A43:
## : :...credit_amount <= 6110: no (5)
## : credit_amount > 6110: yes (2)
## savings_balance in {A61,A62,A63}:
## :...months_loan_duration > 47: yes (23/3)
## months_loan_duration <= 47:
## :...employment_duration = A71:
## :...years_at_residence <= 2: yes (7)
## : years_at_residence > 2: no (12/2)
## employment_duration = A72:
## :...years_at_residence <= 1: no (16/6)
## : years_at_residence > 1:
## : :...job in {A171,A172,A174}: yes (11/1)
## : job = A173:
## : :...percent_of_income <= 2: no (4)
## : percent_of_income > 2: yes (12/1)
## employment_duration = A75:
## :...job = A173:
## : :...other_credit = A141: yes (6)
## : : other_credit in {A142,A143}: no (13/2)
## : job in {A171,A172}:
## : :...purpose in {A40,A49}: yes (2)
## : : purpose in {A41,A410,A42,A43,A44,A45,A46,
## : : A48}: no (5)
## : job = A174:
## : :...dependents > 1: no (3)
## : dependents <= 1:
## : :...age <= 37: no (3)
## : age > 37: yes (5)
## employment_duration = A73:
## :...housing = A153: yes (5)
## : housing in {A151,A152}:
## : :...percent_of_income > 3: yes (17/3)
## : percent_of_income <= 3:
## : :...credit_history = A33: no (3)
## : credit_history = A34: yes (5/2)
## : credit_history = A32:
## : :...phone = A191: yes (13/5)
## : phone = A192: no (6/1)
## employment_duration = A74:
## :...savings_balance in {A62,A63}: no (8)
## savings_balance = A61:
## :...job in {A171,A172,A174}: no (6)
## job = A173:
## :...dependents > 1: no (3/1)
## dependents <= 1:
## :...months_loan_duration <= 22: no (3)
## months_loan_duration > 22: yes (8)
##
## ----- Trial 1: -----
##
## Decision tree:
##
## checking_balance = A14:
## :...other_credit in {A141,A142}:
## : :...employment_duration = A74: no (7.9)
## : : employment_duration in {A71,A72,A73,A75}:
## : : :...months_loan_duration <= 8: no (4)
## : : months_loan_duration > 8:
## : : :...age > 44: no (10.1/2.2)
## : : age <= 44:
## : : :...purpose in {A40,A44,A45,A46,A48,A49}: yes (30.4/2.4)
## : : purpose in {A41,A410,A42,A43}: no (20.5/8.6)
## : other_credit = A143:
## : :...credit_history in {A30,A31,A34}: no (100.4/4.3)
## : credit_history in {A32,A33}:
## : :...existing_loans_count <= 1:
## : :...savings_balance in {A62,A64,A65}: no (39.7)
## : : savings_balance in {A61,A63}:
## : : :...age > 29: no (40.9/4.3)
## : : age <= 29:
## : : :...months_loan_duration <= 7: no (5.6)
## : : months_loan_duration > 7: yes (34.5/15.1)
## : existing_loans_count > 1:
## : :...existing_loans_count > 2: yes (2.2)
## : existing_loans_count <= 2:
## : :...years_at_residence <= 1: yes (4.3)
## : years_at_residence > 1:
## : :...housing in {A151,A153}: yes (10.2/1.6)
## : housing = A152: no (26.3/6.5)
## checking_balance in {A11,A12,A13}:
## :...credit_history in {A30,A31}:
## :...age <= 23: no (6.7/0.8)
## : age > 23: yes (61.5/14.3)
## credit_history in {A32,A33,A34}:
## :...purpose in {A40,A44,A45,A46,A48}:
## :...percent_of_income > 2:
## : :...other_credit in {A141,A142}: yes (19.5/1.6)
## : : other_credit = A143:
## : : :...checking_balance = A12: yes (35.4/16.7)
## : : checking_balance = A13: no (6.1/2.2)
## : : checking_balance = A11:
## : : :...job in {A171,A174}: no (5.3/0.8)
## : : job in {A172,A173}: yes (57.3/10.3)
## : percent_of_income <= 2:
## : :...credit_amount > 11760: yes (8.1)
## : credit_amount <= 11760:
## : :...months_loan_duration <= 8: no (8.7)
## : months_loan_duration > 8:
## : :...other_credit in {A141,A142}: no (7.2/1.6)
## : other_credit = A143:
## : :...credit_amount <= 3643: yes (25.2/7.2)
## : credit_amount > 3643: no (15.7/1.6)
## purpose in {A41,A410,A42,A43,A49}:
## :...savings_balance in {A63,A64,A65}: no (57.3/13.6)
## savings_balance = A62:
## :...purpose in {A41,A410,A49}: no (13/0.8)
## : purpose in {A42,A43}: yes (17.6/4)
## savings_balance = A61:
## :...months_loan_duration > 36: yes (19.4/4.5)
## months_loan_duration <= 36:
## :...existing_loans_count > 1: no (44.1/12)
## existing_loans_count <= 1:
## :...credit_amount > 7393: yes (8.3/0.8)
## credit_amount <= 7393:
## :...age > 48: no (9.5)
## age <= 48:
## :...employment_duration = A71: yes (4/0.8)
## employment_duration in {A74,
## : A75}: no (28.7/10.4)
## employment_duration = A72:
## :...job in {A171,A174}: no (5.3)
## : job in {A172,A173}:
## : :...phone = A191: no (24.5/9.6)
## : phone = A192: yes (8.3/1.6)
## employment_duration = A73:
## :...credit_history = A33: no (0)
## credit_history = A34: yes (3.7/0.8)
## credit_history = A32:
## :...phone = A192: no (7.9/0.8)
## phone = A191: [S1]
##
## SubTree [S1]
##
## checking_balance = A11: no (26.4/5.6)
## checking_balance in {A12,A13}: yes (28.1/10.9)
##
## ----- Trial 2: -----
##
## Decision tree:
##
## checking_balance = A14:
## :...other_credit = A143: no (241.7/48.4)
## : other_credit in {A141,A142}:
## : :...employment_duration = A74: no (6.4)
## : employment_duration in {A71,A72,A73,A75}:
## : :...months_loan_duration <= 8: no (3.2)
## : months_loan_duration > 8:
## : :...housing = A151: yes (8.9/1.3)
## : housing = A153: no (7.6/3.5)
## : housing = A152:
## : :...savings_balance in {A61,A63,A65}: yes (37.5/11.2)
## : savings_balance in {A62,A64}: no (4.1)
## checking_balance in {A11,A12,A13}:
## :...months_loan_duration > 11:
## :...checking_balance = A11:
## : :...job = A174: no (27.3/8.4)
## : : job in {A171,A172,A173}:
## : : :...purpose in {A40,A41,A44,A45,A46,A48}: yes (95.3/30.5)
## : : purpose in {A410,A49}: no (11.6/4.1)
## : : purpose = A43:
## : : :...employment_duration in {A71,A72,A73,A74}: yes (34/6.3)
## : : : employment_duration = A75: no (2.6)
## : : purpose = A42:
## : : :...other_credit = A141: yes (12.3/0.6)
## : : other_credit = A142: no (1.3)
## : : other_credit = A143:
## : : :...credit_amount <= 1987: no (10.1/0.6)
## : : credit_amount > 1987:
## : : :...years_at_residence <= 2: no (13.1/4.4)
## : : years_at_residence > 2: yes (20.9/6.5)
## : checking_balance in {A12,A13}:
## : :...savings_balance = A63: yes (17.2/8.3)
## : savings_balance = A64: no (12.1/3.3)
## : savings_balance = A62:
## : :...housing = A151: yes (11.8/3.5)
## : : housing in {A152,A153}: no (32.4/9.8)
## : savings_balance = A65:
## : :...checking_balance = A12: no (31.7/5.8)
## : : checking_balance = A13: yes (7.2/2.6)
## : savings_balance = A61:
## : :...months_loan_duration > 42: yes (8.8)
## : months_loan_duration <= 42:
## : :...months_loan_duration > 40: no (6.2)
## : months_loan_duration <= 40:
## : :...employment_duration in {A71,A74}: no (25.4/8.9)
## : employment_duration in {A72,A75}: yes (62.4/23.1)
## : employment_duration = A73:
## : :...percent_of_income <= 3: no (26/5.1)
## : percent_of_income > 3: yes (16.3/5.8)
## months_loan_duration <= 11:
## :...employment_duration = A74: no (12.7)
## employment_duration in {A71,A72,A73,A75}:
## :...job = A174: yes (13.3/3.9)
## job in {A171,A172,A173}:
## :...housing = A153: yes (4.8/0.6)
## housing in {A151,A152}:
## :...age > 32: no (34.1)
## age <= 32:
## :...existing_loans_count > 1: no (3.2)
## existing_loans_count <= 1:
## :...months_loan_duration > 9: no (4.6)
## months_loan_duration <= 9:
## :...months_loan_duration <= 8: no (15.1/6.5)
## months_loan_duration > 8: yes (16.7/5.1)
##
## ----- Trial 3: -----
##
## Decision tree:
##
## credit_amount > 9566: yes (47.5/12.7)
## credit_amount <= 9566:
## :...checking_balance = A11:
## :...months_loan_duration <= 11: no (33.2/8.2)
## : months_loan_duration > 11:
## : :...purpose in {A41,A48}: no (26/8.6)
## : purpose in {A410,A44,A45,A46,A49}: yes (34.5/12.7)
## : purpose = A42:
## : :...other_credit = A141: yes (10.9/1.2)
## : : other_credit in {A142,A143}: no (52.9/24.3)
## : purpose = A40:
## : :...years_at_residence <= 2: yes (19.6/4.3)
## : : years_at_residence > 2:
## : : :...housing in {A151,A153}: yes (17.2/6.5)
## : : housing = A152: no (20.3/5.8)
## : purpose = A43:
## : :...months_loan_duration > 33: yes (7)
## : months_loan_duration <= 33:
## : :...credit_amount <= 3249: yes (31.4/12.6)
## : credit_amount > 3249: no (6.7/0.5)
## checking_balance in {A12,A13,A14}:
## :...purpose in {A41,A410,A44,A48}: no (61.2/4.8)
## purpose = A45: yes (17/7.1)
## purpose = A40:
## :...other_credit in {A141,A142}: yes (24.1/7.4)
## : other_credit = A143: no (99.1/32.9)
## purpose = A43:
## :...age <= 22: yes (12/2.8)
## : age > 22: no (174.8/41.6)
## purpose = A46:
## :...other_credit = A142: yes (2.3)
## : other_credit in {A141,A143}:
## : :...phone = A191: yes (19.3/7.9)
## : phone = A192: no (11/1.5)
## purpose = A42:
## :...other_credit = A142: no (7.1)
## : other_credit in {A141,A143}:
## : :...employment_duration = A75: no (14.9/1.3)
## : employment_duration in {A71,A72,A73,A74}:
## : :...dependents > 1: yes (6.3/0.5)
## : dependents <= 1:
## : :...credit_amount > 4473: yes (8.5/0.5)
## : credit_amount <= 4473:
## : :...checking_balance = A12: yes (25/10.5)
## : checking_balance in {A13,A14}: no (38.2/11.7)
## purpose = A49:
## :...existing_loans_count > 2: yes (5.2/0.5)
## existing_loans_count <= 2:
## :...percent_of_income <= 1: no (7.2)
## percent_of_income > 1:
## :...years_at_residence <= 1: no (10.5/1.5)
## years_at_residence > 1:
## :...dependents > 1: yes (11.2/3.4)
## dependents <= 1:
## :...credit_amount <= 1924: no (9.9)
## credit_amount > 1924: yes (27.9/11.6)
##
## ----- Trial 4: -----
##
## Decision tree:
##
## checking_balance = A14:
## :...employment_duration in {A74,A75}: no (118.4/21.8)
## : employment_duration in {A71,A72,A73}:
## : :...credit_amount > 4153: yes (49.6/15.3)
## : credit_amount <= 4153:
## : :...percent_of_income <= 1: no (14.5)
## : percent_of_income > 1:
## : :...purpose in {A41,A410,A43,A44,A48}: no (30/2)
## : purpose in {A40,A42,A45,A46,A49}:
## : :...other_credit in {A141,A142}: yes (12.2/2.5)
## : other_credit = A143: no (56.3/23.8)
## checking_balance in {A11,A12,A13}:
## :...credit_history = A31: yes (39.4/16.2)
## credit_history = A30:
## :...housing in {A151,A153}: yes (9.9)
## : housing = A152: no (24/9.7)
## credit_history = A33:
## :...percent_of_income <= 1: no (7.8)
## : percent_of_income > 1:
## : :...housing in {A151,A153}: no (13.3/1.8)
## : housing = A152: yes (27.9/10.1)
## credit_history = A32:
## :...savings_balance in {A63,A64}: no (23.6/6.5)
## : savings_balance = A65:
## : :...credit_amount <= 5866: no (31.3/9.5)
## : : credit_amount > 5866: yes (14.4/2.1)
## : savings_balance = A62:
## : :...months_loan_duration > 27: yes (9.9)
## : : months_loan_duration <= 27:
## : : :...credit_amount <= 836: yes (5.6)
## : : credit_amount > 836: no (24.6/7.5)
## : savings_balance = A61:
## : :...job = A171: yes (1.7)
## : job = A172: no (58/24.7)
## : job = A174:
## : :...credit_amount <= 7596: no (23.8/3.6)
## : : credit_amount > 7596: yes (10.7/1.8)
## : job = A173:
## : :...years_at_residence <= 1:
## : :...housing = A151: yes (7.6/0.9)
## : : housing in {A152,A153}: no (26.1/4.1)
## : years_at_residence > 1:
## : :...other_credit in {A141,A142}: yes (10.6/1.5)
## : other_credit = A143:
## : :...checking_balance = A13: no (11.7/1.9)
## : checking_balance in {A11,A12}:
## : :...percent_of_income > 2: yes (61.9/20.4)
## : percent_of_income <= 2:
## : :...housing in {A151,A153}: no (11.2)
## : housing = A152: yes (25.7/10.9)
## credit_history = A34:
## :...age > 61: no (8.6)
## age <= 61:
## :...years_at_residence <= 1: no (10.2/1.2)
## years_at_residence > 1:
## :...years_at_residence <= 2: yes (27.7/9.2)
## years_at_residence > 2:
## :...employment_duration = A74: no (16.4/1.1)
## employment_duration in {A71,A72,A73,A75}:
## :...age > 57: yes (4.9)
## age <= 57:
## :...age > 46: no (15.3/1.2)
## age <= 46:
## :...existing_loans_count > 2: no (8.1/1.1)
## existing_loans_count <= 2:
## :...phone = A191: no (26.9/10.9)
## phone = A192: yes (20.3/5.1)
##
## ----- Trial 5: -----
##
## Decision tree:
##
## credit_history = A30: yes (40.4/15.8)
## credit_history = A34:
## :...age > 33: no (121.8/25.5)
## : age <= 33:
## : :...job = A171: no (0)
## : job in {A172,A174}: yes (30.3/12)
## : job = A173:
## : :...savings_balance in {A62,A65}: no (15.7/3.5)
## : savings_balance in {A63,A64}: yes (9.8/3.2)
## : savings_balance = A61:
## : :...housing = A151: yes (9.6/3.4)
## : housing = A153: no (3.7)
## : housing = A152:
## : :...months_loan_duration <= 33: no (22.5/5.6)
## : months_loan_duration > 33: yes (7.7/1.6)
## credit_history in {A31,A32,A33}:
## :...purpose in {A41,A410,A48}: no (65.9/17.5)
## purpose in {A44,A45}: yes (25.9/10.3)
## purpose = A46:
## :...phone = A191: yes (17.4/5.5)
## : phone = A192: no (14.4/2.9)
## purpose = A49:
## :...other_credit = A142: no (5.1)
## : other_credit in {A141,A143}:
## : :...checking_balance in {A11,A13,A14}: yes (30.2/12.1)
## : checking_balance = A12: no (22.2/5)
## purpose = A40:
## :...savings_balance in {A62,A63}: yes (29.7/11.6)
## : savings_balance = A64: no (3.8)
## : savings_balance = A65:
## : :...months_loan_duration <= 42: yes (23.4/10)
## : : months_loan_duration > 42: no (5.2)
## : savings_balance = A61:
## : :...percent_of_income <= 2:
## : :...credit_history = A31: yes (2.2)
## : : credit_history in {A32,A33}: no (27/6.7)
## : percent_of_income > 2:
## : :...other_credit in {A141,A142}: yes (6.1)
## : other_credit = A143:
## : :...credit_amount > 2284: yes (16.7/1.3)
## : credit_amount <= 2284:
## : :...dependents <= 1: yes (23.4/9.5)
## : dependents > 1: no (6.5/0.4)
## purpose = A42:
## :...other_credit = A142: no (7.6)
## : other_credit in {A141,A143}:
## : :...credit_history = A31: yes (5.7)
## : credit_history in {A32,A33}:
## : :...job in {A171,A174}: yes (20/3.9)
## : job = A172:
## : :...percent_of_income <= 1: no (5.9)
## : : percent_of_income > 1: yes (24.9/7.3)
## : job = A173:
## : :...housing = A153: no (5.7)
## : housing in {A151,A152}:
## : :...phone = A191: yes (52.2/22.1)
## : phone = A192: no (10.7/1.9)
## purpose = A43:
## :...employment_duration = A71: yes (9.1/1.6)
## employment_duration = A75: no (30.7/5.9)
## employment_duration in {A72,A73,A74}:
## :...percent_of_income <= 1: yes (14/4.1)
## percent_of_income > 1:
## :...years_at_residence <= 1: no (17.3/1.4)
## years_at_residence > 1:
## :...savings_balance in {A62,A63}: yes (16.2/5.1)
## savings_balance in {A64,A65}: no (8.8/1.5)
## savings_balance = A61:
## :...checking_balance in {A12,A14}: no (42.3/8.1)
## checking_balance = A13: yes (12.8/2.7)
## checking_balance = A11:
## :...job in {A171,A172,A173}: yes (23.7/7.3)
## job = A174: no (5.8)
##
## ----- Trial 6: -----
##
## Decision tree:
##
## checking_balance in {A11,A12,A13}:
## :...housing = A153:
## : :...job in {A171,A174}: no (27.5/10)
## : : job in {A172,A173}: yes (46.3/14.4)
## : housing = A151:
## : :...credit_history = A30: yes (4.1)
## : : credit_history = A33: no (8.2/0.9)
## : : credit_history in {A31,A32,A34}:
## : : :...months_loan_duration > 33: yes (7.3/0.3)
## : : months_loan_duration <= 33:
## : : :...savings_balance in {A62,A65}: yes (17.8/6.5)
## : : savings_balance in {A63,A64}: no (11.5/3.5)
## : : savings_balance = A61:
## : : :...checking_balance in {A12,A13}: no (23.3/6.9)
## : : checking_balance = A11:
## : : :...phone = A192: yes (13.3/2.1)
## : : phone = A191:
## : : :...purpose in {A40,A41,A410,A42,A44,A45,
## : : : A49}: no (20.6/4)
## : : purpose in {A43,A46,A48}: yes (8.8/0.7)
## : housing = A152:
## : :...purpose in {A41,A44,A45,A48,A49}: no (86.2/22.7)
## : purpose in {A410,A46}: yes (20.4/8.2)
## : purpose = A40:
## : :...dependents <= 1: yes (91.4/42.4)
## : : dependents > 1: no (21.6/6.8)
## : purpose = A42:
## : :...other_credit = A142: no (6.1)
## : : other_credit in {A141,A143}:
## : : :...savings_balance in {A62,A63}: yes (3.9)
## : : savings_balance in {A64,A65}: no (11/2)
## : : savings_balance = A61:
## : : :...employment_duration = A74: yes (5.9)
## : : employment_duration in {A71,A72,A73,A75}:
## : : :...age <= 52: no (58.9/22.5)
## : : age > 52: yes (3.7)
## : purpose = A43:
## : :...months_loan_duration > 36: yes (12.6/1.1)
## : months_loan_duration <= 36:
## : :...employment_duration = A71: yes (4.1)
## : employment_duration in {A74,A75}: no (30.4/4.3)
## : employment_duration in {A72,A73}:
## : :...savings_balance in {A62,A63}: yes (13.3/3.6)
## : savings_balance in {A64,A65}: no (2.7)
## : savings_balance = A61:
## : :...checking_balance = A13: yes (14.3/3.7)
## : checking_balance in {A11,A12}:
## : :...phone = A191: no (33.5/4.6)
## : phone = A192: yes (9.4/3.3)
## checking_balance = A14:
## :...other_credit = A141:
## :...months_loan_duration <= 8: no (4)
## : months_loan_duration > 8:
## : :...percent_of_income <= 1: no (5.2/0.9)
## : percent_of_income > 1:
## : :...percent_of_income <= 3: yes (18.9/4.8)
## : percent_of_income > 3: no (21.1/9)
## other_credit in {A142,A143}:
## :...purpose in {A41,A410,A44,A48}: no (29.1)
## purpose in {A40,A42,A43,A45,A46,A49}:
## :...credit_history in {A30,A31}: no (5.5/0.9)
## credit_history = A33:
## :...percent_of_income <= 3: no (9.9/1.4)
## : percent_of_income > 3: yes (23.9/7.9)
## credit_history = A34:
## :...credit_amount <= 11054: no (52.6/6.3)
## : credit_amount > 11054: yes (3)
## credit_history = A32:
## :...employment_duration in {A74,A75}: no (36.9/3)
## employment_duration in {A71,A72,A73}:
## :...existing_loans_count > 1: yes (11.3/1.1)
## existing_loans_count <= 1:
## :...savings_balance in {A62,A64,A65}: no (15.2)
## savings_balance in {A61,A63}:
## :...months_loan_duration > 24: yes (7.7)
## months_loan_duration <= 24:
## :...phone = A192: no (8.1)
## phone = A191:
## :...years_at_residence <= 3: no (18.4/5.8)
## years_at_residence > 3: yes (11.4/2.2)
##
## ----- Trial 7: -----
##
## Decision tree:
##
## checking_balance in {A13,A14}:
## :...other_credit = A142: no (20.8/7.9)
## : other_credit = A143:
## : :...employment_duration in {A73,A74,A75}: no (196.2/43.6)
## : : employment_duration in {A71,A72}:
## : : :...purpose in {A40,A41,A410,A44,A48}: no (11.4)
## : : purpose in {A42,A43,A45,A46,A49}: yes (40.8/14.8)
## : other_credit = A141:
## : :...existing_loans_count > 2: no (3.5)
## : existing_loans_count <= 2:
## : :...job = A171: no (0)
## : job = A172: yes (15.2/3)
## : job in {A173,A174}:
## : :...months_loan_duration <= 16: no (8.3)
## : months_loan_duration > 16:
## : :...age <= 32: no (15.6/3.4)
## : age > 32: yes (19/6)
## checking_balance in {A11,A12}:
## :...savings_balance in {A63,A64}: no (43.6/15.9)
## savings_balance = A62:
## :...employment_duration in {A71,A72}: yes (18.6/4)
## : employment_duration in {A73,A74,A75}: no (45/13.8)
## savings_balance = A65:
## :...credit_history in {A30,A33,A34}: no (17.8)
## : credit_history in {A31,A32}:
## : :...checking_balance = A11: yes (23.2/8.4)
## : checking_balance = A12: no (28.4/7.3)
## savings_balance = A61:
## :...months_loan_duration > 15:
## :...years_at_residence <= 1: no (35.8/12.9)
## : years_at_residence > 1:
## : :...purpose in {A40,A42,A44,A45,A46,A48,A49}: yes (120.1/31.8)
## : purpose in {A41,A410}: no (33.9/14.9)
## : purpose = A43:
## : :...employment_duration in {A71,A72,A73,A74}: yes (29.3/9.6)
## : employment_duration = A75: no (6.5)
## months_loan_duration <= 15:
## :...employment_duration = A75:
## :...age <= 30: no (5)
## : age > 30: yes (31.6/6.6)
## employment_duration in {A71,A72,A73,A74}:
## :...credit_history in {A30,A31}: yes (8.3/2.4)
## credit_history in {A33,A34}: no (30.4/4)
## credit_history = A32:
## :...job in {A171,A174}: no (6.5)
## job in {A172,A173}:
## :...months_loan_duration > 12: no (13.3/0.7)
## months_loan_duration <= 12:
## :...phone = A192: no (12.4/1.2)
## phone = A191:
## :...housing in {A151,A153}: yes (12.1/2.8)
## housing = A152:
## :...purpose in {A40,A42,A45,
## : A46}: yes (32/11.5)
## purpose in {A41,A410,A43,A44,A48,
## A49}: no (14.4)
##
## ----- Trial 8: -----
##
## Decision tree:
##
## checking_balance = A14:
## :...employment_duration = A74: no (29.3)
## : employment_duration in {A71,A72,A73,A75}:
## : :...other_credit in {A141,A142}:
## : :...months_loan_duration <= 8: no (5.2)
## : : months_loan_duration > 8:
## : : :...years_at_residence <= 2: yes (33.1/11.1)
## : : years_at_residence > 2: no (28/11.4)
## : other_credit = A143:
## : :...purpose in {A41,A410,A43,A44,A46,A48}: no (57.3/2.9)
## : purpose in {A40,A42,A45,A49}:
## : :...credit_amount > 7685: yes (8.2/1)
## : credit_amount <= 7685:
## : :...credit_history in {A30,A31,A34}: no (17.9)
## : credit_history in {A32,A33}:
## : :...purpose = A45: yes (3.9)
## : purpose in {A40,A42,A49}:
## : :...employment_duration in {A71,A75}: no (10.8)
## : employment_duration in {A72,A73}:
## : :...job in {A171,A172,A173}: no (42.5/17.3)
## : job = A174: yes (5.6/0.8)
## checking_balance in {A11,A12,A13}:
## :...credit_amount > 9283: yes (40.4/9.1)
## credit_amount <= 9283:
## :...dependents > 1:
## :...credit_history in {A30,A31}: yes (13.1/1)
## : credit_history in {A32,A33,A34}:
## : :...phone = A192: no (23.5/4.8)
## : phone = A191:
## : :...other_credit in {A141,A142}: yes (9.6/1)
## : other_credit = A143:
## : :...credit_amount <= 1264: yes (15.6/2.5)
## : credit_amount > 1264: no (31.3/9.7)
## dependents <= 1:
## :...months_loan_duration > 30:
## :...employment_duration = A71: no (7)
## : employment_duration in {A72,A73,A74,A75}:
## : :...years_at_residence > 3: yes (25.2/2.7)
## : years_at_residence <= 3:
## : :...housing = A153: no (2.8)
## : housing in {A151,A152}:
## : :...years_at_residence > 2: yes (3.7)
## : years_at_residence <= 2:
## : :...savings_balance = A64: yes (0)
## : savings_balance in {A63,A65}: no (6.8)
## : savings_balance in {A61,A62}:
## : :...age <= 29: yes (16.6/2.8)
## : age > 29: no (14.3/5.3)
## months_loan_duration <= 30:
## :...years_at_residence > 3: no (167.3/52.8)
## years_at_residence <= 3:
## :...months_loan_duration <= 8: no (20.2/0.5)
## months_loan_duration > 8:
## :...purpose in {A41,A410,A48,A49}: no (27.9/5.5)
## purpose in {A44,A45,A46}: yes (18.3/5)
## purpose = A42:
## :...employment_duration in {A71,A75}: yes (12.4/0.5)
## : employment_duration in {A72,A73,A74}: no (50.5/17.1)
## purpose = A43:
## :...employment_duration = A71: yes (3)
## : employment_duration = A75: no (4.9)
## : employment_duration in {A72,A73,A74}:
## : :...credit_amount <= 2622: yes (51.9/20.9)
## : credit_amount > 2622: no (14.3/2.3)
## purpose = A40:
## :...credit_amount <= 983: yes (10.3)
## credit_amount > 983:
## :...credit_amount > 5511: no (7)
## credit_amount <= 5511:
## :...housing = A151: yes (6.7)
## housing = A153: no (1.3)
## housing = A152:
## :...credit_amount <= 3711: no (40.3/12.8)
## credit_amount > 3711: yes (5)
##
## ----- Trial 9: -----
##
## Decision tree:
##
## checking_balance in {A13,A14}: no (275/69.5)
## checking_balance in {A11,A12}:
## :...housing in {A151,A153}:
## :...credit_history = A33: no (15.2/3.6)
## : credit_history = A30: yes (11.7)
## : credit_history in {A31,A32,A34}:
## : :...savings_balance in {A62,A64}: yes (23.1/4.6)
## : savings_balance in {A63,A65}: no (28.3/13)
## : savings_balance = A61:
## : :...percent_of_income > 3: yes (53.5/14.6)
## : percent_of_income <= 3:
## : :...employment_duration = A74: no (8.7/0.4)
## : employment_duration in {A71,A72,A73,A75}:
## : :...housing = A151: yes (33.5/10.1)
## : housing = A153: no (22.8/9.1)
## housing = A152:
## :...months_loan_duration <= 16:
## :...purpose in {A41,A410,A44,A45,A48,A49}: no (26.5/5.4)
## : purpose = A46: yes (5.9/1)
## : purpose = A42:
## : :...checking_balance = A11: no (16.3/1.7)
## : : checking_balance = A12: yes (14/3.8)
## : purpose = A43:
## : :...job in {A171,A172,A173}: no (47.6/8.5)
## : : job = A174: yes (2.5)
## : purpose = A40:
## : :...existing_loans_count > 1: no (21.9/6.5)
## : existing_loans_count <= 1:
## : :...dependents > 1: yes (6.6/1.1)
## : dependents <= 1:
## : :...credit_amount <= 1372: yes (17.1/3.4)
## : credit_amount > 1372: no (17.7/3.5)
## months_loan_duration > 16:
## :...savings_balance in {A62,A64,A65}: no (58.5/22.7)
## savings_balance = A63: yes (6.2/2.8)
## savings_balance = A61:
## :...other_credit = A141: yes (25.2/5.7)
## other_credit = A142: no (8.8/3.3)
## other_credit = A143:
## :...age > 62: no (6.5/1)
## age <= 62:
## :...employment_duration in {A71,A72,A74}: yes (60.5/19.7)
## employment_duration = A75: no (14.5/5)
## employment_duration = A73:
## :...existing_loans_count > 2: yes (3.2)
## existing_loans_count <= 2:
## :...years_at_residence <= 3: yes (38/10.5)
## years_at_residence > 3: no (9.7/0.7)
##
##
## Evaluation on training data (900 cases):
##
## Trial Decision Tree
## ----- ----------------
## Size Errors
##
## 0 43 136(15.1%)
## 1 42 178(19.8%)
## 2 37 203(22.6%)
## 3 33 218(24.2%)
## 4 38 190(21.1%)
## 5 44 247(27.4%)
## 6 46 187(20.8%)
## 7 30 186(20.7%)
## 8 40 170(18.9%)
## 9 29 193(21.4%)
## boost 55( 6.1%) <<
##
##
## (a) (b) <-classified as
## ---- ----
## 630 5 (a): class no
## 50 215 (b): class yes
##
##
## Attribute usage:
##
## 100.00% checking_balance
## 100.00% credit_history
## 100.00% credit_amount
## 99.89% purpose
## 94.22% employment_duration
## 85.11% other_credit
## 84.44% savings_balance
## 77.67% age
## 76.44% months_loan_duration
## 73.67% housing
## 73.44% years_at_residence
## 70.00% percent_of_income
## 66.56% job
## 66.56% dependents
## 60.22% existing_loans_count
## 36.44% phone
##
##
## Time: 0.1 secs
credit_boost_pred10 <- predict(credit_boost10, credit_test)
CrossTable(credit_test$default, credit_boost_pred10,
prop.chisq = FALSE, prop.c = FALSE, prop.r = FALSE,
dnn = c('actual default', 'predicted default'))
##
##
## Cell Contents
## |-------------------------|
## | N |
## | N / Table Total |
## |-------------------------|
##
##
## Total Observations in Table: 100
##
##
## | predicted default
## actual default | no | yes | Row Total |
## ---------------|-----------|-----------|-----------|
## no | 59 | 6 | 65 |
## | 0.590 | 0.060 | |
## ---------------|-----------|-----------|-----------|
## yes | 20 | 15 | 35 |
## | 0.200 | 0.150 | |
## ---------------|-----------|-----------|-----------|
## Column Total | 79 | 21 | 100 |
## ---------------|-----------|-----------|-----------|
##
##
matrix_dimensions <- list(c("no", "yes"), c("no", "yes"))
names(matrix_dimensions) <- c("predicted", "actual")
matrix_dimensions
## $predicted
## [1] "no" "yes"
##
## $actual
## [1] "no" "yes"
error_cost <- matrix(c(0, 1, 4, 0), nrow = 2, dimnames = matrix_dimensions)
error_cost
## actual
## predicted no yes
## no 0 4
## yes 1 0
credit_cost <- C5.0(credit_train[-17], credit_train$default,
costs = error_cost)
credit_cost_pred <- predict.C5.0(credit_cost, credit_test)
CrossTable(credit_test$default, credit_cost_pred,
prop.chisq = FALSE, prop.c = FALSE, prop.r = FALSE,
dnn = c('actual default', 'predicted default'))
##
##
## Cell Contents
## |-------------------------|
## | N |
## | N / Table Total |
## |-------------------------|
##
##
## Total Observations in Table: 100
##
##
## | predicted default
## actual default | no | yes | Row Total |
## ---------------|-----------|-----------|-----------|
## no | 38 | 27 | 65 |
## | 0.380 | 0.270 | |
## ---------------|-----------|-----------|-----------|
## yes | 8 | 27 | 35 |
## | 0.080 | 0.270 | |
## ---------------|-----------|-----------|-----------|
## Column Total | 46 | 54 | 100 |
## ---------------|-----------|-----------|-----------|
##
##