Ask Your Question

SVM Train error: (-215:Assertion failed) problem

asked 2018-11-18 23:33:33 -0500

cnrblm gravatar image

image description

Hi. I want to use svm for classification. I created train and label data. When i ran svm.train method, I see these errors

OpenCV(3.4.2) /io/opencv/modules/ml/src/svm.cpp:1381: error: (-215:Assertion failed) _samples.type() == 5 in function 'do_train'
svm.train(X,, y)

Any suggestions. Thanks.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2018-11-19 01:01:48 -0500

berak gravatar image

updated 2018-11-19 01:09:21 -0500

it wants float32 for the data, and int32 for the labels, int64 is wrong for both x and y. you also need numpy arrays, not plain lists


X = np.asarray(X, np.float32)
y = np.asarray(y, np.int32)
svm.train(X,, y)
edit flag offensive delete link more

Question Tools

1 follower


Asked: 2018-11-18 23:33:33 -0500

Seen: 257 times

Last updated: Nov 19 '18