7.1. Exercises

Testing your SVM RBF Knowledge

These two boundary plots were made using SVM with an RBF kernel and the other with K-Nearest Neighbours.

404 image

SVM True or False

Predicting with an SVM Classifier

Instructions:
Running a coding exercise for the first time could take a bit of time for everything to load. Be patient, it could take a few minutes.

When you see ____ in a coding exercise, replace it with what you assume to be the correct code. Run it and see if you obtain the desired output. Submit your code to validate if you were correct.

Make sure you remove the hash (#) symbol in the coding portions of this question. We have commented them so that the line wonโ€™t execute and you can test your code after each step.

Weโ€™ve used K-Nearest Neighbours to classify Pokรฉmon from the Pokรฉmon dataset so now letโ€™s try to do the same thing with an RBF kernel!

Tasks:

  • Create an SVM model with gamma equal to 0.1 and C equal to 10 then name the model model.
  • Train your model on X_train and y_train (Hint: you may want to use .to_numpy()).
  • Score your model on the training set using .score() and save it in an object named train_score.
  • Score your model on the test set using .score() and save it in an object named test_score.
Hint 1
  • Are you using SVM(gamma=0.1, C=10)?
  • Are you using model.fit(X_train, y_train)?
  • Are you using model.score(X_test, y_test) to find the test score?
Fully worked solution: