Using Regressor along with OpenCV SVM Class

asked 2018-06-03 02:39:50 -0500

krshrimali gravatar image

There is a function from old libsvm module:

score = svm_predict_probability(model, x, prob_estimates);

Where model is the trained model, x is the struct svm_node (like a dictionary, having value and indexes) and prob_estimates is defined as:

int nr_class=svm_get_nr_class(model);

double prob_estimates = (double *) malloc(nr_classsizeof(double));

I want to use it using OpenCV SVM Class. it's aregression problem where score (the final output) ranges from 0 to 100. I'm not sure how to do it? (Except loading the svm model and it's parameters).

edit retag flag offensive close merge delete

Comments

hi ;)

what's your data like ? how many classes ?

berak gravatar imageberak ( 2018-06-03 03:22:40 -0500 )edit
1

Hello again @berak. Well, I've taken database from http://live.ece.utexas.edu/research/Q... and classes - there are around 6 classes to know which distortion was there.

krshrimali gravatar imagekrshrimali ( 2018-06-03 03:28:58 -0500 )edit

oh, this brisque thing again.

berak gravatar imageberak ( 2018-06-03 04:13:47 -0500 )edit
krshrimali gravatar imagekrshrimali ( 2018-06-03 07:20:11 -0500 )edit
1

idk, maybe you should stick with libsvm here ? (as uncomfortable and awkward as it is..)

opencv's svm does not have a proper way to calculate probabilites. you can use RAW_OUTPUT in the prediction, but that only gives you the distance to the margin (which only makes sense in a 2-class context, so you'd have to split it into 6 one-class-against-all-others SVM's). you would need PLATT scaling (or, lacking that, because A,B would need to be calculated in the training, maybe a simple sigmoid function), to make probabilities from that.

berak gravatar imageberak ( 2018-06-04 00:32:36 -0500 )edit

Oh! Yes, @berak ... I think this is a better idea compared to what other options I've. Thanks again for your help and time.

krshrimali gravatar imagekrshrimali ( 2018-06-04 00:37:00 -0500 )edit

btw, what are your 2 classes ?

berak gravatar imageberak ( 2018-06-04 00:37:10 -0500 )edit

2 classes? I guess there are 6 classes.

krshrimali gravatar imagekrshrimali ( 2018-06-04 00:37:53 -0500 )edit
1

ok. thanks. misread it from the allmodel then. (the training code has indeed 65 !!)

berak gravatar imageberak ( 2018-06-04 00:42:04 -0500 )edit

nr_class in allmodel says 2... Hmm, need to recheck what are the 2 classes then.

krshrimali gravatar imagekrshrimali ( 2018-06-04 00:43:29 -0500 )edit