Binary predictions (2)
Let's continue to explore the predictions of our model.
This exercise is part of the course
Helsinki Open Data Science
Exercise instructions
- Initialize the ggplot object and define
probability
as the x axis andhigh_use
as the y axis. - Use
geom_point()
to draw the plot. - Add the aesthetic element
col = prediction
and draw the plot again. - Use
table()
to create a cross table of 'high_use' versus 'prediction' - Adjust the code: Use
%>%
to apply theprop.table()
function on the output oftable()
- Adjust the code: Use
%>%
to apply theaddmargins()
function on the output ofprop.table()
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# alc is available
# access dplyr and ggplot2
library(dplyr); library(ggplot2)
# initialize a plot of 'high_use' versus 'probability' in 'alc'
g <- ggplot(alc, aes(x = "change me!", y = "change me!"))
# define the geom as points and draw the plot
# tabulate the target variable versus the predictions
table(high_use = alc$high_use, prediction = alc$prediction)