split_by | R Documentation |
The split_by() splits the data.frame or tbl_df into a train set and a test set.
split_by(.data, ...) ## S3 method for class 'data.frame' split_by(.data, target, ratio = 0.7, seed = NULL, ...)
.data |
a data.frame or a |
... |
further arguments passed to or from other methods. |
target |
unquoted expression or variable name. the name of the target variable |
ratio |
numeric. the ratio of the train dataset. default is 0.7 |
seed |
random seed used for splitting |
The split_df class is created, which contains the split information and criteria to separate the training and the test set.
An object of split_by.
The attributes of the split_df class are as follows.:
split_seed : integer. random seed used for splitting
target : character. the name of the target variable
binary : logical. whether the target variable is binary class
minority : character. the name of the minority class
majority : character. the name of the majority class
minority_rate : numeric. the rate of the minority class
majority_rate : numeric. the rate of the majority class
library(dplyr) # Credit Card Default Data head(ISLR::Default) # Generate data for the example sb <- ISLR::Default %>% split_by(default) sb
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.