Get startedGet started for free

Binary predictions (2)

Let's continue to explore the predictions of our model.

This exercise is part of the course

Helsinki Open Data Science

View Course

Exercise instructions

  • Initialize the ggplot object and define probability as the x axis and high_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 the prop.table() function on the output of table()
  • Adjust the code: Use %>% to apply the addmargins() function on the output of prop.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)


Edit and Run Code