1
$\begingroup$

I am trying to split a data set into training and test set with these codes

 table (A)
       A
    No   Yes 

  21343  4419 
  
  set.seed(88)  
  split <- sample.split(mydata$A, SplitRatio = 0.75)  
  train <- subset(mydata, split == TRUE)  
  test <- subset(mydata, split == FALSE)
  table(train$A)

   No   Yes 
 16007  3314 
>table(test$A)

   No  Yes 
  5336 1105 

I want to ask that is there any way to get equal number of responses in training or test set?? that is, for training set number of responses for YES and NO will be 3314 ??

$\endgroup$
1
  • 1
    $\begingroup$ Because you can randomly take samples of size 3314 from each of the "Yes" and "No" subsets, and this is so simple, I suppose you are trying to ask something else. But what, exactly? $\endgroup$
    – whuber
    Commented Jul 24 at 20:35

0

Browse other questions tagged or ask your own question.