Session Ready
Exercise

Visualizing decision boundaries and margins

In the previous exercise you built two linear classifiers for a linearly separable dataset, one with cost = 1 and the other cost = 100. In this exercise you will visualize the margins for the two classifiers on a single plot. The following objects are available for use:

  • The training dataset: trainset.
  • The cost = 1 and cost = 100 classifiers in svm_model_1 and svm_model_100, respectively.
  • The slope and intercept for the cost = 1 classifier is stored in slope_1 and intercept_1.
  • The slope and intercept for the cost = 100 classifier is stored in slope_100 and intercept_100.
  • Weight vectors for the two costs are stored in w_1 and w_100, respectively
  • A basic scatter plot of the training data is stored in train_plot

The ggplot2 library has been preloaded.

Instructions 1/2
undefined XP
  • 1
  • 2
  • Add the decision boundary and margins for the cost = 1 classifier to the training data plot.
  • Display the resulting plot.