DataFrameに対して、TrainingSetとTestSetに分けて、Predictionの前処理を行う
Predictionを行う際に、DataFrameを training set と test set に分ける必要がある。
よく使う方法なので、コピペできるようにメモしておく。
dfというデータフレームがあるとする。
train_index = sample(1:nrow(df), size=nrow(df)/2 , replace=F)
trainDf = df[train_index,]
testDf = df[-train_index,]
とこんな感じで用意しておくとよい。