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
Exercise instructions
- Obtain the observed purchases for
HOPPINESS
fromchoice.data
and assign them to an objectobserved
. - Cross-tabulate the
observed
andpredicted
data vectors by using the functiontable()
. Divide the result by2798
. - Cross-tabulate the
observed
andpredicted
data vectors by using the functiontable()
. Apply the functionprop.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))