Custom SVM optimization using LIBLINEAR or LIBSVM

410 views Asked by At

I have a PU learning task, and I found what looks like an exceptional algorithim for solving it in this paper: https://www.cs.uic.edu/~liub/publications/ICDM-03.pdf

I wish to implement a non-standard formulation of a 'biased' SVM as described in part 5.

which uses two parameters C+ and C- to weight positive errors and negative errors differently.

I thought I would use an existing SVM solver on this problem to not only expedite legwork but also ensure an optimal time complexity since both my feature space and number of samples are extremely large (hence my desire to use LIBLINEAR).

Is there any way to specify a custom loss function like the one above?

Thanks for the help.

1

There are 1 answers

0
Hudson Cooper On BEST ANSWER

LIBLINEAR 'train' takes an argument -wi weight: "weights adjust the parameter C of different classes". Its actual use (does it take an array?) is still unclear to me, even after reading the README. But Sklearn's LinearSVC uses LIBLINEAR and offers a parameter:

class_weight : {dict, ‘balanced’}, optional Set the parameter C of class i to class_weight[i]*C for SVC. If not given, all classes are supposed to have weight one. The “balanced” mode uses the values of y to automatically adjust weights inversely proportional to class frequencies in the input data as n_samples / (n_classes * np.bincount(y))

Which is quite useful.