首页 > 代码库 > python 实现 svm算法

python 实现 svm算法

svm算法,说到底就是二次优化问题。

带有约束的二次优化问题。

1、线性优化问题,课件Leture5-QP

技术分享

参考 https://www.coin-or.org/PuLP/CaseStudies/a_blending_problem.html

python代码:

# problem
def qp_test1():
prob = LpProblem("qp_test1", LpMinimize)
x1 = LpVariable("x1", 0, None, LpInteger)
x2 = LpVariable("x2", 0, None, LpInteger)

prob += 50*x1+36*x2, "Cost"
prob += x1>=0, "x1"
prob += x2>=0, "x2"
prob += 5*x1+3*x2>=45, "cond1"

prob.solve()

print("Status:", LpStatus[prob.status])
for v in prob.variables():
print(v.name, "=", v.varValue)

 

2.二次优化问题

python 实现 svm算法