如何使用createDataPartition()调整datasplit大小

时间:2017-01-26 18:30:43

标签: r validation testing r-caret

我有一个关于数据分析到火车,测试和放大器的问题。使用createDataPartition()进行验证。我找到了一个适合60,20,20分割的解决方案。但是,我没有看到一种方法来调整我的数据分割,仍然确保我的数据不重叠。即,我想分成80,10,10或其他任何东西。

    library("caret")
    # Draw a random, stratified sample including p percent of the data    
    idx.train <- createDataPartition(y = iris$Species, p = 0.8, list = FALSE) 
    # training set with p = 0.8
    train <- iris[idx.train, ] 
    # test set with p = 0.2 (drop all observations with train indeces)
    test <-  iris[-idx.train, ] 
    # Draw a random, stratified sample of ratio p of the data
    idx.validation <- createDataPartition(y = train$Species, p = 0.25, list = FALSE) 
    #validation set with p = 0.8*0.25 = 0.2
    validation <- train[idx.validation, ] 
    #final train set with p= 0.8*0.75 = 0.6
    train60 <- train[-idx.validation, ] 

0 个答案:

没有答案