Ask Your Question
0

While using the cv::SVM::autoTrain OpenCV function, can one model be retrained and augmented multiple times with newer data?

asked 2017-04-08 16:02:55 -0600

dohnjoe gravatar image

I want to use SVM.autoTrain in OpenCV.

Say I have N samples, I train an SVM model using these N samples using cv::SVM::autoTrain().

Say I have another M samples of data.

I used the same above trained model with cv::SVM::autoTrain to train these M samples.

Will this overwrite the previously trained model (trained with N samples) with one created now with M samples?

OR

Will this augment the previously created model (with N samples) with the M samples? (That is, will the model created in this case be equivalent to the case if the M+N samples were part of the same dataset fed to the SVM together?)

There is very good documentation about cv::SVM but not anything that elaborates on this issue exactly.

Thanks

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2017-04-08 20:18:14 -0600

berak gravatar image

an SVM cannot be "augmented" (or "updated") with additional data. it will clear all internal structure and start to learn from scratch, (though you can do that with ANN_MLP or LogisticRegression)

edit flag offensive delete link more

Comments

Really? Even if I declare the svm model once and then sequentially autotrain using N+M samples? Wont the parameters and support vectors learned from N live on and be used as an initial starting point for the M samples? (because I dont delete the original svm model itself, so there must be some persistance). Can you show me the code to back this up, that the SVM model itself gets erased?

dohnjoe gravatar imagedohnjoe ( 2017-04-08 21:55:50 -0600 )edit
1
berak gravatar imageberak ( 2017-04-09 01:55:44 -0600 )edit

@berak is right. As of now, there is no possibility to augment SVM models. What you could do, is create an override function with a flag, where you can disable the clearing. If you decide to do so, feel free to provide a PR! It might actually be as simple as

  1. Setting a flag condition at the line @berak quoted
  2. Then at line 1616 collect the old data, add the new data by concatenation and run the process again.

Wanna try it out?

StevenPuttemans gravatar imageStevenPuttemans ( 2017-04-10 03:29:12 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-04-08 15:35:05 -0600

Seen: 425 times

Last updated: Apr 08 '17