Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

ok, you found a bug !

problem is here

instead of

digit = model.predict(sample)[0]

it must be:

digit = model.predict(sample)[1].ravel()

ok, you found a bug !

problem is here

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)