Get startedGet started for free

Model confusion

On demand, you built a naive classifier. The brewery's management wants to work with these figures to adjust their marketing plan. So, is your classification really correct?

By cross-tabulating the observed vs. the classified purchase events you can check the performance of your classifier. Cross-tabulation can be done by using the function table() on the predicted purchase events together with the true observed purchases. To obtain relative numbers, you additionally divide the table by the total number of observations. Alternatively, you can use the function prop.table() to convert the numbers in the table into relative numbers.

This exercise is part of the course

Building Response Models in R

View Course

Exercise instructions

  • Obtain the observed purchases for HOPPINESS from choice.data and assign them to an object observed.
  • Cross-tabulate the observed and predicted data vectors by using the function table(). Divide the result by 2798.
  • Cross-tabulate the observed and predicted data vectors by using the function table(). Apply the function prop.table() on the result.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Obtain the observed purchases
observed <- ___

# Cross-tabulate observed vs. predicted purchases
___(predicted, observed)/___

# Cross-tabulate observed vs. predicted purchases
___(___(predicted, observed))
Edit and Run Code