1
$\begingroup$

I have created a model in KERAS R, using a data table, with the following script:

data <- 'csv filename'
data %<>% mutate_if(is.factor, as.numeric)
data <- data[, c(1:35,30)]
data <- data[ -c(31) ]
data <- as.matrix(data)

set.seed(1234)

ind <- sample(2, nrow(data), replace = T, prob = c(.7, .3))
training <- data[ind==1,6:29]
test <- data[ind==2,6:29]

trainingtarget <- data[ind==1,31]
testtarget <- data[ind==2,31]

m <- colMeans(training)
s <- apply(training, 2, sd)
training <- scale(training, center = m, scale = s)
test <- scale(test, center = m, scale = s)

model <- keras_model_sequential()

model %>% layer_dense(units = 10, activation = 'relu', input_shape = c(24)) %>% layer_dense(units = 5, activation = 'relu') %>% layer_dense (units = 1)
model %>% compile(loss = 'mse', optimizer = 'rmsprop', metrics = 'mae')

mymodel <- model %>% fit(training, trainingtarget, epochs = 100, batch_size = 32, validation_spit = 0.2)

I use this model to make predictions on another table, called 'newtest', using the following command:

y_data_pred=predict_classes(model, newdata)
glimpse(y_data_pred)

I have installed LIME into R Studio, however I am struggling to get the correct LIME script syntax to explain my model predictions, to plot these in a chart, etc.

Any help would be greatly appreciated.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.