updating svm code
This commit is contained in:
@@ -743,18 +743,12 @@ Finally, the vector $\bm{h}$ is defined as
|
||||
|
||||
|
||||
Since we don't have any equalities the matrix $\bm{A}$ is set to zero
|
||||
The following code does this for us
|
||||
The following code solves the equations for us
|
||||
!bc pycod
|
||||
# Import the necessary packages
|
||||
import numpy
|
||||
from cvxopt import matrix
|
||||
from cvxopt import solvers
|
||||
# Define QP parameters (directly)
|
||||
P = matrix([[1.0,0.0],[0.0,0.0]])
|
||||
q = matrix([3.0,4.0])
|
||||
G = matrix([[-1.0,0.0,-1.0,2.0,3.0],[0.0,-1.0,-3.0,5.0,4.0]])
|
||||
h = matrix([0.0,0.0,-15.0,100.0,80.0])
|
||||
# Define QP parameters (with NumPy)
|
||||
P = matrix(numpy.diag([1,0]), tc=’d’)
|
||||
q = matrix(numpy.array([3,4]), tc=’d’)
|
||||
G = matrix(numpy.array([[-1,0],[0,-1],[-1,-3],[2,5],[3,4]]), tc=’d’)
|
||||
@@ -773,7 +767,7 @@ We are now ready to return to our setup of the optmization problem for a more re
|
||||
!bt
|
||||
\[
|
||||
\frac{1}{2} \bm{\lambda}^T\begin{bmatrix} y_1y_1K(\bm{x}_1,\bm{x}_1) & y_1y_2K(\bm{x}_1,\bm{x}_2) & \dots & \dots & y_1y_nK(\bm{x}_1,\bm{x}_n) \\
|
||||
y_2y_1\bm{x}_2^T\bm{x}_1 & y_2y_2\bm{x}_2^T\bm{x}_2 & \dots & \dots & y_1y_n\bm{x}_2^T\bm{x}_n \\
|
||||
y_2y_1K(\bm{x}_2,\bm{x}_1) & y_2y_2K(\bm{x}_2,\bm{x}_2) & \dots & \dots & y_1y_nK(\bm{x}_2,\bm{x}_n) \\
|
||||
\dots & \dots & \dots & \dots & \dots \\
|
||||
\dots & \dots & \dots & \dots & \dots \\
|
||||
y_ny_1K(\bm{x}_n,\bm{x}_1) & y_ny_2K(\bm{x}_n\bm{x}_2) & \dots & \dots & y_ny_nK(\bm{x}_n,\bm{x}_n) \\
|
||||
|
||||
Reference in New Issue
Block a user