1. Learn
  2. /
  3. Courses
  4. /
  5. Helsinki Open Data Science

Connected

Exercise

Predict LDA

Like in the regression, the function predict() can be used to predict values based on a model. The function arguments are almost the same. You can see the help page of prediction function for LDA with ?predict.lda.

We split our data earlier so that we have the test set and the correct class labels. See how the LDA model performs when predicting on new (test) data.

Instructions

100 XP
  • Predict the crime classes with the test data. Like in regression, the predict() function takes the model object as a first argument.
  • Create a table of the correct classes and the predicted ones. You can get the predicted classes with lda.pred$class.
  • Look at the table. Did the classifier predict the crime rates correctly?