Question: Can you please help me with Task 3, my output is not matching the expected output. You need to called the parameters. solution = import

Can you please help me with Task 3, my output is notmatching the expected output. You need to called the parameters. solution =import quadprog import numpy as np # The helper function. Dot notCan you please help me with Task 3, my output is not matching the expected output. You need to called the parameters. solution =

import quadprog import numpy as np # The helper function. Dot not change it def quadprog_solve_qp(P, q, G=None, h=None, A=None, b=None) : qp_G = .5 * (P + P.T) # make sure P is symmetric qp_a = -9 if A is not None: qp_C -np.vstack([A, G]).I -np. hstack([b, h]). A. shape [0] else: # no equality constraint qp_C = -G.T qp_b = -h. meq = 0 return quadprog.solve_qp(qp_G, qp_a, qp_C, qp_b, meq)[0] qp_b meg # Toy data X = np.array ( [ [0, 0], [2, 0], [0, 2], [3, 3], [4, 4] ]). Y = np.array([-1, -1, -1, 1, 1]) Task We want to build an SVM model on the toy dataset: (3) (4) x(!) = (0,0), y(") = -1 x(2) = (2,0), (2) = -1 = (0,2), y) = -1 = (3,3), (4) = 1 x(5) = (4,4), y) = 1 We need to solve the quadratic programming (QP) problem as the following form: min la" Qa - (1)a) subject to: y a = 0, a > 0 The quadprog package by defaualt solves the QP as this form: min (x? Px+q"x) subject to: Gx 0, ]) 118518.51508526 118518.51508526 44444.45472745 [100] solution = [100000. 25925.93964519] The support vectors are: [20] [0 2] (3 3] [44]] Expected output solution [O. 0.125 0.125 0.25 0] The support vectors are: [[20] [O 2] [33]] import quadprog import numpy as np # The helper function. Dot not change it def quadprog_solve_qp(P, q, G=None, h=None, A=None, b=None) : qp_G = .5 * (P + P.T) # make sure P is symmetric qp_a = -9 if A is not None: qp_C -np.vstack([A, G]).I -np. hstack([b, h]). A. shape [0] else: # no equality constraint qp_C = -G.T qp_b = -h. meq = 0 return quadprog.solve_qp(qp_G, qp_a, qp_C, qp_b, meq)[0] qp_b meg # Toy data X = np.array ( [ [0, 0], [2, 0], [0, 2], [3, 3], [4, 4] ]). Y = np.array([-1, -1, -1, 1, 1]) Task We want to build an SVM model on the toy dataset: (3) (4) x(!) = (0,0), y(") = -1 x(2) = (2,0), (2) = -1 = (0,2), y) = -1 = (3,3), (4) = 1 x(5) = (4,4), y) = 1 We need to solve the quadratic programming (QP) problem as the following form: min la" Qa - (1)a) subject to: y a = 0, a > 0 The quadprog package by defaualt solves the QP as this form: min (x? Px+q"x) subject to: Gx 0, ]) 118518.51508526 118518.51508526 44444.45472745 [100] solution = [100000. 25925.93964519] The support vectors are: [20] [0 2] (3 3] [44]] Expected output solution [O. 0.125 0.125 0.25 0] The support vectors are: [[20] [O 2] [33]]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!