O'Reilly logo

R Data Analysis Cookbook - Second Edition by Kuntal Ganguly

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Case 3 - Categorical target variable and two partitions

The boston-housing-classification.csv file has a MEDV_CAT variable that categorizes the median values into HIGH or LOW, and is suitable for a classification algorithm.

For partitioning the categorical response variable with 70-30 split, use the following commands:

> bh2 <- read.csv("boston-housing-classification.csv") > trg.idx <- createDataPartition(bh2$MEDV_CAT, p=0.7, list =     FALSE) > trg.part <- bh2[trg.idx, ] > val.part <- bh2[-trg.idx, ] 

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required