Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1065351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T19:47:25+00:00 2026-05-16T19:47:25+00:00

With StompChicken’s corrections (I miscomputed one dot product, ugh!) the answer appears to be

  • 0

With StompChicken’s corrections (I miscomputed one dot product, ugh!) the answer appears to be yes. I have since tested the same problem using a precomputed kernel with the same correct results. If you are using libsvm StompChickens clear, organized computations are a very nice check.

Original Question:
I am about to start using precomputed kernels in libSVM. I had noticed
Vlad’s answer to a question and I thought it would be wise to confirm that libsvm gave correct answers. I started with non-precomputed kernels, just a simple linear kernel with 2 classes and three data points in 3 dimensional space. I used the data

1 1:3 2:1 3:0
2 1:3 2:3 3:1
1 1:7 3:9

The model file generated by a call to svm-train -s 0 - t 0 contains

svm_type c_svc
kernel_type linear
nr_class 2
total_sv 3
rho -1.53951
label 1 2
nr_sv 2 1
SV
0.4126650675419768 1:3 2:1 3:0 
0.03174528241667363 1:7 3:9 
-0.4444103499586504 1:3 2:3 3:1 

However when I compute the solution by hand that is not what I get. Does anyone know whether libsvm suffers from errors or can anyone compare notes and see whether they get the same thing libsvm does?

The coefficients a1, a2, a3 returned by libsvm are should be the values that make

a1 + a2 + a3 - 5*a1*a1 + 12*a1*a2 - 21*a1*a3 - 19*a2*a2/2 + 21*a2*a3 - 65*a3*a3 

as large as possible with the restrictions that
a1 + a3 = a2
and each of a1, a2, a3 is required to lie between 0 and 1 (the default value of C).

The above model file says the answer is

a1 = .412665...
a2 = .444410...
a3 = .031745...

But one just has to substitute a2 = a1 + a3 into the big formula above and confirm both partial derivatives are zero to see if this solution is correct (since none of a1,a2,a3 is 0 or 1) but they are not zero.

Am I doing something wrong, or is libsvm giving bad results? (I am hoping I am doing something wrong.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T19:47:25+00:00Added an answer on May 16, 2026 at 7:47 pm

    LibSVM is a very widely used library and I highly doubt anything is drastically wrong with the code. That said, I think it’s great that there are people who are paranoid enough to actually check it for correctness – well done!

    The solution seems correct according to the working that I give below. What I mean by that is it satisfies the KKT conditions (15.29). It also true that the partial derivatives of the dual vanish at the solution.

    Here’s my working…

    x1 = (3,1,0)  x2 = (3,3,1)  x3 = (7,0,9)
    y1 = -1       y2 = 1        y3 = -1
    
    K = [10   12   21]
        [12   19   30]
        [21   30  130]
    
    L_dual = a1 + a2 + a3 -5a1^2 + 12a1a2 - 21a1a3 - (19/2)a2^2 + 30a2a3 - 65a3^2)
    
    a1 = 0.412  a2 = 0.4444  a3 = 0.0317
    
    Checking KKT:
    y1.f(x1) = y1 * (y1*a1*K(x1,x1) + y2*a2*K(x1,x2) + y3*a3*k(x1,x3) - rho)
             = rho + 10*a1 + 21*a3 - 12*a2
             ~= 1
    (Similar for the x2 and x3)
    
    Substituting a2 = a1 + a3 into L_dual:
    L_dual = 2a1 + 2a3 - 2.5a1^2 + 2a1a3 - 44.5a3^2
    dL/da1 = 2 - 5a1 + 2a3 = 0
    dL/da3 = 2 + 2a1 - 89a3 = 0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to find words (specifically physical objects) related to a single word.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.