Code chunk highlights the Keras API
library(keras)
# Build model
model <- keras_model_sequential()
model %>%
layer_dense(units = 14, activation = 'relu', kernel_initializer='RandomNormal',
input_shape = c(13)) %>%
# Training data samples/Factor * (Input Neurons + Output Neurons)
layer_dense(units = 65, activation = 'relu') %>%
layer_dense(units = 1, activation = 'linear')
# Train model
model %>% compile( loss = 'mean_squared_error', optimizer = 'adam',
metrics = c('mae') )
history <- model %>% fit( X_train, y_train, epochs = 30,
batch_size = 50, validation_split = 0.2 )
model %>% evaluate(X_val, y_val)
# Predictions
pred <- data.frame(y = predict(model, as.matrix(X_val)))
Source: towardsdatascience.com/keras-and-r-predicting-blood-glucose-levels-with-the-sequential-model-596efe89a6b8