Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I remember seeing/reading somewhere that for multiclass SVMs with unbalanced data, there was a way to determine the class weights from the training data (rather than X validation). Does anyone know what the method is or what paper its from?


share|improve this question
Did you find a good solution for multiclass svm? – Vam Dec 12 '13 at 7:39

For SVM that minimizes objective function $$\frac{1}{2}||w||^2 + C_1 \sum_{\xi_i: y_i=-1}^{l}\xi_i + C_2 \sum_{\xi_i: y_i=1}^{l}\xi_i $$ you can choose constants $C_1$ and $C_2$ inversely proportional to the class sizes. That is, if you have $l_1$ training samples in class 1 and $l_2$ -- in class 2, take $C_1$ and $C_2$ such that $C_1/C_2$ = $l_2/l_1$. You may need to slightly adjust them later in your experiments, but this is a good rule of thumb.

If you are using LIBSVM package, you can specify $C_1$ and $C_2$ using flags ''-w-1'' and "-w1".

P.S. I just noticed that you asked about multiclass problem. Well, maybe you will still find this answer useful.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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