Tobjan Brejicz

2010-12-29 19:16:58 UTC

Hello:

I want to understand better liblinear multiclass decision function.

array([2, 2, 0, 1, 2, 1, 0, 0, 0, 2, 2, 2, 1, 2, 0, 2, 0, 1, 0, 2, 0, 0, 0,

2, 2, 2, 0, 2, 2, 0])

(80,10000)

array([1, 0, 0, 1, 0, 0, 2, 2, 2, 2, 0, 0, 1, 2, 0, 2, 0, 1, 0, 2, 0, 0, 0,

....

0, 0, 2, 2, 2,1, 0])

I want to know what is definition of predict procedure in terms of this

data. In one way, maybe I already understand, because when using my self

(3,10000)

problem

myclassifer.intercept).argmax(axis = 1)

True

This work for several problems and many splits so I think it is true that

liblinear is using OVA. (Or please tell me if not true.) BUT: if I try

same maximum margin with original weight and intercept from classifier, is

classifer.intercept).argmax(axis = 1)

False

So, what is relationship between coef, intercept from classifier returned by

LinearSVC, and prediction function? I look at liblinear source code, but I

don't know c++ so I didn't understand. Also documentation was not too

explicit.

Thank you.

Tobjan

I want to understand better liblinear multiclass decision function.

##TrF is array of 30 training feature vectors with 10000 features

(30,10000)TrF.shape

TrL

2, 2, 2, 0, 2, 2, 0])

import scikits.learn.svm as svm

classifier = svm.LinearSVC(eps = 1e-5, C = 10**4)

classifier.fit(TrF,TrL)

TeF.shape

classifier = svm.LinearSVC(eps = 1e-5, C = 10**4)

classifier.fit(TrF,TrL)

TeF.shape

prediction = classifier.predict(TeF)

prediction

prediction

....

0, 0, 2, 2, 2,1, 0])

coef = classifier.coef_

intercept = classifier.intercept_

intercept = classifier.intercept_

data. In one way, maybe I already understand, because when using my self

OVA_classifier = my_ova_classifier(TrF,TrL)

##OVA_classifier.coef is matrix of coefficients from binary problem for

OVA_classifier.coef.shape

##OVA_classifier.coef is matrix of coefficients from binary problem for

OVA_classifier.coef.shape

## where OVA_classifier[i,:] is weights for i-th class binary problem

## OVA_classifier.intercept is array of intercepts also from binary

## OVA_classifier.intercept is array of intercepts also from binary

OVA_prediction = (dot(TeF,myclassifier.coef) +

(OVA_prediction == prediction).all()

This work for several problems and many splits so I think it is true that

liblinear is using OVA. (Or please tell me if not true.) BUT: if I try

same maximum margin with original weight and intercept from classifier, is

not_prediction = (dot(TeF,classifier.coef.T) +

(not_prediction == prediction).all()

So, what is relationship between coef, intercept from classifier returned by

LinearSVC, and prediction function? I look at liblinear source code, but I

don't know c++ so I didn't understand. Also documentation was not too

explicit.

Thank you.

Tobjan