library(tidyverse)
<-
biopsies read_csv("https://www.dropbox.com/s/0rbzonyrzramdgl/cells.csv?dl=1") |>
mutate(diagnosis = factor(diagnosis, levels = c("B", "M")))
Lab 6: Diagnosing Cancer
Part I: Understanding the Context of the Data
Part II: Computing on the Data
You can load in the biopsies
data frame using the code below:
The diagnosis is in the column named diagnosis
; each other column should be used to predict the diagnosis.
Make a single plot that examines the association between
radius_mean
andradius_sd
separately for each diagnosis (hint:aes()
should have three arguments).Calculate the correlation between these two variables for each diagnosis.
Give at least a two-sentence interpretation of the results in the last two questions. In particular, comment on:
Is the relationship between
radius_mean
andradius_sd
different for benign biopsies vs. malignant biopsies?If so, can you give an explanation for this difference?
Split the data set into a roughly 80-20 train-test set split.
Using the training data, fit a simple logistic regression model that predicts the diagnosis using the mean of the texture index.
Using a threshold of .5, What would your model predict for a biopsy with a mean texture of 15? What probability does it assign to that outcome?
Calculate and report two misclassification rates for your simple model: first on the training data and then on the testing data.
Build a more complex model to predict the diagnosis using five predictors of your choosing.
Calculate and report two misclassification rates for your complex model: first on the training data and then on the testing data.
Is there any evidence that your model is overfitting? Explain in at least two sentences.
Move back to your simple model for the next few questions.Report the total number of false negatives in the test data set.
What can you change about your classification rule to lower the number of false negatives?
Make the change you identified in the previous question and calculate the new number of false negatives.
Calculate the testing misclassification rate using your new classification rule.
Did your misclassification rule go up or down? Answer this question and explain why it went up or down in at least two sentences.