OK, time to get into Keras. We should leave apart a small fraction of the data to use as a validation or test set, and develop the model on the remaining. There is no golden standard as to how this should be done. For this example, we will use a 10% test set and a 90% training set:
# Remove the time and class columnidxs <- sample(nrow(df), size=0.1*nrow(df))train <- df[-idxs,]test <- df[idxs,]y_train <- train$Classy_test <- test$ClassX_train <- train %>% select(-one_of(c("Time","Class")))X_test <- test %>% select(-one_of(c("Time","Class")))# Coerce the data frame to matrix to perform the trainingX_train <- as.matrix(X_train)X_test <- as.matrix(X_test)
Notice that we also excluded the Class and Time columns. ...