# NOT RUN {
#We will use the cancer dataset to build a GLM model to predict cancer status
#this will detail whether the patient has a benign or malignant
library(mlbench)
library(caret)
library(tibble)
library(ggplot2)
library(OddsPlotty)
library(e1071)
library(ggthemes)
#Bring in the data
data("BreastCancer", package = "mlbench")
breast <- BreastCancer[complete.cases(BreastCancer), ]
breast <- breast[, -1]
head(breast, 10)
breast$Class <- factor(breast$Class)
for(i in 1:9) {
breast[, i] <- as.numeric(as.character(breast[, i]))
}
#Train GLM model
glm_model <- train(Class ~ ., data = breast, method = "glm", family = "binomial")
#Visualise the data with OddsPlotty
plotty <- OddsPlotty::odds_plot(glm_model$finalModel,title = "Odds Plot")
plotty$odds_plot
#Extract underlying odds ratios
plotty$odds_data
# }
Run the code above in your browser using DataLab