Split Dataset into TrainSet & TestSet

Split Dataset into TrainSet & TestSet

  • In Library menu selects caTools
    • install that library by writing following line into R Script
      • install.packages('caTools')
      • only one time after comment it.
  • Select that library
  • Split data into TrainSet & TestSet

#split data into Train Set & Text Set
set.seed(123)
split = sample.split( dataset$Purchased , SplitRatio = 0.8)
train_set = subset( dataset , split==TRUE)
test_set = subset( dataset , split==FALSE)

  • If you write this code then it splits dataset into train_set & test_set
  • It generates train_set & test_set  Global variable data

Comments

Popular posts from this blog

Download DataSet

Categorical Data