Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

If I understood http://pyml.sourceforge.net/doc/howto.pdf and http://www.csie.ntu.edu.tw/~cjlin/papers/libsvm.pdf correctly, this should work with the class_weights-parameter, which serves as a penalty, i.e. assign a higher weight to the class having more samples.

Example: 400 pos, 100 neg --> class_weight for positive class = 4/5 = 0.8 and 0.2 for the negative class.

Note that for other classifiers this can often be achieved by giving a class-prior. Also note that if you have an unbalanced test (not training) set then a proper error measurement (e.g. unweighted average precision/recall, Vinciarelli et al. "The INTERSPEECH 2012 Speaker Trait Challenge") should be used.

Btw. as far as I know OpenCV's SVM is based on libSVM.