fit of model not working

here is the data preprocessing and model defining code. I continue to get a user code error and do not know why .

data("BreastCancer")
BreastCancer <- BreastCancer[which(complete.cases(BreastCancer)==TRUE),]

breastCancer <- as_tibble(BreastCancer)
breastCancer$Mitoses <- as.numeric(breastCancer$Mitoses)

ggplot(breastCancer, aes(Bl.cromatin)) +
geom_density()

breastCancerSplit <- initial_split(BreastCancer, prop = .8, strata = 'Class')

breastCancerTraining <- training(breastCancerSplit)
breastCancerTest <- testing(breastCancerSplit)

breastCancerRecipe <- recipe(Class ~ ., data = breastCancerTraining) %>%
step_rm(Id) %>%
step_dummy(Class) %>%
prep()

breastCancerTrainingPreped <- bake(breastCancerRecipe, new_data = breastCancerTraining)
breastCancerTestPreped <- bake(breastCancerRecipe, new_data = breastCancerTest)

breastCancerTrainingPrepedMatrix <- as.matrix(breastCancerTrainingPreped[1:9], rownames.force = F)
breastCancerTrainingPrepedMatrixLabel <- as.matrix(breastCancerTrainingPreped[10], rownames.force = F)

model <- keras_model_sequential() %>%
layer_dense(units = 6, activation = 'relu', input_shape = 9) %>%
layer_dense(units = 6, activation = 'relu') %>%
layer_dense(units = 2, activation = 'softmax')

model %>% compile (
optimizer = optimizer_adam(),
loss = "categorical_crossentropy",
metrics = c('accuracy')
)

history <- model %>% fit(
breastCancerTrainingPrepedMatrix,
breastCancerTrainingPrepedMatrixLabel,
batch_size = 50,
epochs = 30,
validation_split = .2
)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.