Skip to content
nonconvexcard

Implement SMO for the SVM dual

CodingGraduate⏱ 1 dayClassical MLsvmsmoimplementationkktquadratic programming

Problem

Implement sequential minimal optimisation for the soft-margin dual and verify it against a general-purpose QP solver.

  1. Derive the closed-form solution of the two-variable subproblem with clipping.
  2. Implement the working-set selection by maximal KKT violation.
  3. Verify the support-vector classification (the three KKT regimes) on a synthetic problem.
  4. Compare the decision boundary with a kernel of your choice against a linear one.

Implement it, then check the implementation against something you can verify independently.

Write it

Solve it here8 tests · Python runs in your browser
⌘/Ctrl + ↵ to run · limit 90s · draft saved in this browser
8 tests will run against your code. The first run downloads the Python runtime — several megabytes, once per browser.

Solution

Opening this before you have a real attempt on paper is the fastest way to feel like you understand something you cannot reproduce.

Related problems

All problems
SolvedProblemFieldTypeDifficultyTime
The geometric marginClassical MLProofFoundation15 min
Solve a two-point SVM by handClassical MLNumericalBeginner30 min
Complementary slackness and active constraintsAdvanced OptimizationProofIntermediate30 min
Implement backpropagation from scratch runDeep LearningCodingIntermediate3 hours
Implement kernel ridge regression runClassical MLCodingIntermediate1 hour