1 | initial version |
ok, you found a bug !
instead of
digit = model.predict(sample)[0]
it must be:
digit = model.predict(sample)[1].ravel()
2 | No.2 Revision |
ok, you found a bug !
instead of
digit = model.predict(sample)[0]
it must be:
digit = model.predict(sample)[1].ravel()
(longer explanation: the python wrappers treat even a single test sample as a 2d Mat, so the prediction is returned in the results
array, not in the retval
(as it would be in c++). while other ml classes, like RTrees or KNearest at least make an attempt to put the 1st result into the retval
, the SVM simply returns 0 in this case)