Marcus Johansson
Marcus Johansson

Reputation: 2667

Prefer one class in libsvm (python)

I just started playing a bit with libsvm in python and got some simple classification to work.

The problem is that I'm constructing a face detection system, and I want a very low false rejection rate. The svm on the other hand seems to optimize for equal false rejection and false acceptance. What options do I have here?

And as a said earlier, I'm very new to libsvm, so be kind. ;)

Upvotes: 1

Views: 2318

Answers (2)

Ciaran
Ciaran

Reputation: 573

I've been using the python wrapper for libSVM and found I could compute a confidence-measure using the margin... see the "predict_values_raw" function below. It returns a real value, with large positive values indicating high confidence that it IS a class member, large negative values indicating high confidence that it IS NOT a class member; values close to zero indicate that it is not confident about the classification. So instead of calling 'predict', call 'predict_values_raw' and apply a low threshold (e.g. -2) to ensure you don't reject any true faces

# Begin pseudo-code
import svm as svmlib

prob = svmlib.svm_problem(labels, data)
param = svmlib.svm_parameter(svm_type=svmlib.C_SVC, kernel_type = svmlib.RBF)
model = svmlib.svm_model(prob, param)

# get confidence
self.model.predict_values_raw(sample_to_classify)

Upvotes: 1

Gael Varoquaux
Gael Varoquaux

Reputation: 2476

SVMs are not usually thought of as a probabilistic model, but a maximally-discriminant model. Thus I have a hard time formulating your question in the context of what I know of SVMs.

In addition, the Python bindings that come with libSVM are not terribly performant and don't expose all the options of libSVM.

That said, if you are willing to look at other bindings, the scikit-learn's svm bindings are richer and expose some parameters that may come in handy, such as weighted classes, or weighted samples. You might be able to put more emphasis on the class for which you do not want mis-classification.

In addition, the scikit's binding expose a posterior classification probability, but in the case of SVMs, I believe that it relies on a hack (as SVMs are not probabilistic) of libSVM that resamples the classification to have a confidence interval on the prediction.

Upvotes: 2

Related Questions