# Revision history [back]

ok, you found a bug !

problem is here

digit = model.predict(sample)[0]


it must be:

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


ok, you found a bug !

problem is here

digit = model.predict(sample)[0]

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)