Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Assignment 2: Support Vector Machines

Question 1                        10 pts

Please write down the primal form of the hard-margin SVM and derive its dualformation. You are required to upload a PDF file (preferably in one page) to showyour derivation of the dual formulation.

Question 2                         25 pts

Please implement the training and testing algorithms of soft-margin Linear Support Vector Machine from its primal form, that is,

by using CVX. Your implementation should follow the following I/O format:

svm_model = svm_train_primal (data_train, label_train , regularisation_para_C)

test_accuracy = svm_predict_primal (data_test, label_test, svm_model )

Please copy the code snippet for the implementation of those two functions (You can also do this by attaching the screenshot of your code. ).

By setting C=100, run your implementation, please report the solution of b and sum of all dimensions of w solution, e.g., np.sum(w). (For a quick check of the correctness of your code)

Question 3                         20 pts

Please implement the training algorithm of the soft-margin Linear Support Vector Machine from its dual form, that is,

by using CVX. Your implementation should follow the following l/O format:

svm_model = svm_train_dual (data_train, label_train, regularisation_para_C)

Please copy the code snippet for the implementation of this function (You can also do this by attaching the screenshot of your code.).

By setting C= 100, run your implementation, please report the sum of all dimensions of the optimal a, e.g., np.sum(alpha). (For a quick check of the correctness of your code)

Question 4                             10 pts

Write code to obtain the primal problem solution w*,b* from its dual solution o*.Please copy the code snippet for the implementation (You can also do this byattaching the screenshot of your code.).

Question 5                           5 pts

Write code to find the support vectors from the primal problem solutions. Pleaseattach the code snippet for the implementation.

Question 6                             5 pts

Write code to find the support vectors from the dual problem solutions. Please copy the code snippet for the implementation

Question 7                              10 pts

Write code to choose C by using the validation set. Please copy the code snippet for the implementation. Report the test accuracy you get by using the optimal C found inthe validation set.Hint: you can search C from the range{2-10,2-8,2-6,...,210}