-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTarget_Encoding.R
More file actions
25 lines (18 loc) · 1.02 KB
/
Target_Encoding.R
File metadata and controls
25 lines (18 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
rm(list=ls())
library(dplyr)
library(ggplot2)
german.credit <- read.table("http://archive.ics.uci.edu/ml/machine-learning-databases/statlog/german/german.data")
colnames(german.credit) <- c("chk_acct", "duration", "credit_his", "purpose",
"amount", "saving_acct", "present_emp", "installment_rate", "sex", "other_debtor",
"present_resid", "property", "age", "other_install", "housing", "n_credits",
"job", "n_people", "telephone", "foreign", "response")
german.credit$response <- german.credit$response - 1
german.credit$target <- german.credit$response
german.credit$response <- as.factor(german.credit$response)
glimpse(german.credit)
summary(german.credit)
ggplot(german.credit, aes(purpose, ..count..)) +
geom_bar(aes(fill = response), position = "dodge")
german.credit.purpose.agg <- german.credit %>% group_by(purpose)
purpose.target.encoding <- german.credit.purpose.agg %>% summarise(target = mean(target))
summary(purpose.target.encoding)