class_labels of SVM::trainAuto is not consistent with that of SVM::train (Bug #4464)


Added by Jie Yang over 9 years ago. Updated over 9 years ago.


Status:Done Start date:2015-07-05
Priority:Normal Due date:
Assignee:- % Done:

100%

Category:-
Target version:-
Affected version:branch 'master' (3.0-dev) Operating System:Mac OSX
Difficulty: HW Platform:x64
Pull request:

Description

To fix Bug #4030, in SVM.cpp Line 1672

Mat class_labels0 = class_labels;

and Line 1817
class_labels = class_labels0;

are deleted.

However, as a result, class_labels in the model trained by SVM::trainAuto are converted to int ranging from 0...class_count-1. But in SVM::train, the class_labels would be the original class_labels.

Actually, I find these two lines are necessary. The real problem is that when Mat class_labels0 = class_labels; class_labels has no value. The value is assigned by class_labels = data->getClassLabels(); in the latter if-statement.

So after

// temporarily replace class labels with 0, 1, ..., NCLASSES-1
Mat(temp_class_labels).copyTo(class_labels);

class_labels0 does not preserve the orignial class_labels. Finally before the return statement, class_labels = class_labels0;, now class_labels is lost.

My solution is to add class_labels.copyTo(class_labels0); before Mat(temp_class_labels).copyTo(class_labels);


Related issues

related to Bug #4030: AutoTrain fail Done 2014-11-26

Associated revisions

Revision 2ba0d317
Added by Jie Yang over 9 years ago

Fix SVM::trainAuto (Bug #4464)

Fix SVM::trainAuto (Bug #4464)

History

Updated by Jie Yang over 9 years ago

  • % Done changed from 0 to 50
  • Status changed from Open to Incomplete

Updated by Jie Yang over 9 years ago

  • % Done changed from 50 to 100
  • Status changed from Incomplete to Done

Also available in: Atom PDF