Ask Your Question
0

error(-215)

asked 2016-08-16 04:08:23 -0600

littletom gravatar image

updated 2016-08-16 21:35:18 -0600

I've got this "error: (-215) _samples.type() == CV_32F in function cv::ml::SVMImpl::do_train",even if there is no data of the type of CV_32F

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-08-16 04:20:11 -0600

berak gravatar image

updated 2016-08-16 04:20:54 -0600

ok, that's a c++ assertion (you have to read it "the other way round").

_samples.type() should be CV_32F, but wasn't.

in other words, to train an SVM, you need a 2d numpy float array, with each feature being one row,

edit flag offensive delete link more

Comments

well,I've finished it as you said,however,and it goes again "error: (-215) samples.type() == CV_32F || samples.type() == CV_32S in function cv::ml::TrainDataImpl::setData"

littletom gravatar imagelittletom ( 2016-08-16 04:39:53 -0600 )edit

please add your code to the question then.

berak gravatar imageberak ( 2016-08-16 04:41:12 -0600 )edit

look.The format has became mess.I can explain it if you need

littletom gravatar imagelittletom ( 2016-08-16 04:48:05 -0600 )edit

yea, quite a mess. still your labels should be int, not float.

can you print out the shape & type of your traindata ? i guess, it's not a 2d numpy array

why are you casting pcl,nam,sex, etc. to int ?

berak gravatar imageberak ( 2016-08-16 04:53:28 -0600 )edit

it is:

>>> type(traindata)
<type 'numpy.ndarray'>
>>> np.shape(traindata)
(8, 891)
>>> type(labels)
<type 'numpy.ndarray'>
>>> np.shape(labels)
(891,)
littletom gravatar imagelittletom ( 2016-08-16 04:58:43 -0600 )edit
1

I find the type of traindata is not float32 but float64.so,you know. anyway,you are right at begaining.Thank you a lot.

littletom gravatar imagelittletom ( 2016-08-16 05:32:15 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-08-16 04:08:23 -0600

Seen: 3,380 times

Last updated: Aug 16 '16