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 2 - Numerical target variable and three partitions

Some machine learning techniques require three partitions, because they use two partitions just for building the model. Thus, the third (test) partition contains the hold out data for model evaluation.

Suppose we want a training partition with 70 percent of the cases, and the rest divided equally among validation and test partitions. We then use the following commands:

> trg.idx <- createDataPartition(bh$MEDV, p = 0.7, list = FALSE) > trg.part <- bh[trg.idx, ] > temp <- bh[-trg.idx, ] > val.idx <- createDataPartition(temp$MEDV, p = 0.5, list = FALSE) > val.part <- temp[val.idx, ] > test.part <- temp[-val.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