공부/R Programming

Data Science Week 10

혼밥맨 2021. 5. 3. 23:39
반응형

Data Science Week 10

 

Using continuous variable as input variable

- Now we take a continuous variable "age" as predictor (input variable) to make prediction

- To use 'age' variable for prediction, we convert it into range variable 'age_group', which contains under 20, 20s, 30s, 40s, 50s, over60

 

summary(adult$age)

 

adult.train$age_group <- cut(adult.train$age, breaks = c(0, 20, 30, 40, 50, 60, Inf), labels = c('under20', '20s', '30s', '40s', '50s', 'over60'), right = F)

 

// right =T (20, 30]

// right = F [20, 30) 오른쪽 포함? False

 

table(adult.train$age_group)

 

 

 

 

 

 

 

반응형