I am using libSVM on a subset of the MNIST, and I am struggling to interpret the output. I have learned that rho is the bias term, and that sv_coef is the multiplier used to get to the weight term. What is confusing me is the dimensions of the outputs:

    Parameters: [5×1 double]
      nr_class: 10
       totalSV: 4282
           rho: [45×1 double]
         Label: [10×1 double]
    sv_indices: []
         ProbA: [45×1 double]
         ProbB: [45×1 double]
           nSV: [10×1 double]
       sv_coef: [4282×9 double]
           SVs: [4282×784 double]

Why do we end up with dimensions of 45 for rho and 9 for the second dimension of sv_coef?


1 Answer 1


As described in here, libsvm uses 1 vs 1 classifiers for multi-class classification (it's not the only option). So, it uses $n(n-1)/2$ binary SVM classifiers internally. Here, that makes $45$ classifiers, which explains the number of bias terms.

sv_coef contains $n-1$ columns. Number of rows is equal to number of SVs. The number of SVs belonging to each class is stored in nSV. For example, let nSV be $[m_1\ m_2\ ...\ m_{10}]$. Then, first $m_1$ rows of sv_coef are $\alpha_iy_i$ coefficients belonging to $1$ vs $x$ classifiers, where $x$ change from $2$ to $10$, making it $9$ columns. The second $m_2$ rows belong to $2$ vs $x$ classifiers, where $x$ is all other classes but $2$ and so on.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.