geanders / csu_msmb

1 stars 11 forks source link

Chapter 12 exercise #66

Closed aef1004 closed 4 years ago

aef1004 commented 4 years ago

Here is the Chapter 12 exercise. Let me know if I should make any additional changes!

geanders commented 4 years ago

@aef1004 : Great start on this! I have some suggestions below for some edits. These are mostly just some suggestions for small edits to the text or areas where it would be helpful to add some explanations or more discussion to the text. As long as we leave the pull request open, any changes that you make and push to your own GitHub repo for this should come straight through this pull request.

predictors <- prostate_train %>% 
  dplyr::select(lcavol:pgg45) %>% 
  as.matrix()
head(predictors)

target <- prostate_train %>% 
  pull(lpsa)

glmnet(x = predictors, 
       y = target, 
       family = "gaussian", alpha = 1)
ggplot(actual_ridge_predict_df, aes(x = actual, y = prediction)) +
  geom_point(color = "#FF62BC", size = 2) +
  geom_abline(slope=1, intercept=0) +
  ggtitle("Ridge Prediction") +
  theme_light() + 
  coord_fixed(xlim = c(0.75, 5.6), 
                       ylim = c(0.75, 5.6))

Since an ideal model would show each plot point to be exactly the same on the x- and y-axes (that is, actual and predicted are always equal), it can be helpful to show this comparison plot in a way that will help in seeing how the real data varies from that ideal. By forcing the scales to have the same ranges, the "equals" diagonal line will cut straight from the bottom left to the top right, and it will be easy to see regions where the model tends to over- or underpredict the values.

geanders commented 4 years ago

@aef1004 : I see that you just pushed several commits with edits a few hours ago (and thank you for making those edits so fast!). Is this now ready for me to merge in and publish on the site? Since you did this in multiple commits, I wanted to make sure that you're set and not merge too soon.

aef1004 commented 4 years ago

@geanders I just finished with a final push, so it should be ready to merge and publish now!

geanders commented 4 years ago

@aef1004 Excellent! It's now published: https://kind-neumann-789611.netlify.app/post/exercise-solution-for-chapter-12/