Ask Your Question

OpenCV Error: Assertion failed ((!varTypesSet && vtypes[i] == rowtypes[i]) ...)& OpenCV Error: Assertion failed (sum > 0)

asked 2017-08-31 23:09:25 -0500

DowYuu gravatar image

updated 2017-09-01 01:05:02 -0500

berak gravatar image

Hi Everyone

I am using

and there is a little part of my data :









but when I trying to use " -ts ord "to train ,it happened:

OpenCV Error: Assertion failed ((!varTypesSet && vtypes[i] == rowtypes[i]) || (varTypesSet && (vtypes[i] == rowtypes[i] || rowtypes[i] == VAR_ORDERED))) in cv::ml::TrainDataImpl::loadCSV, file C:\builds\master_PackSlave-win64-vc12-shared\opencv\modules\ml\src\data.cpp, line 593

and then I tried " -ts cat " ,it happened:

OpenCV Error: Assertion failed (sum > 0) in cv::ml::DTreesImpl::findSplitCatClass, file C:\builds\master_PackSlave-win64-vc12-shared\opencv\modules\ml\src\tree.cpp, line 880

I have read the document for opencv ,but still have no idea what the type_spec is.

Waiting for your answer , thanks !

edit retag flag offensive close merge delete


can you show us, how your cmdline looked, exactly ?

berak gravatar imageberak ( 2017-09-01 00:00:19 -0500 )edit

1 answer

Sort by » oldest newest most voted

answered 2017-09-01 00:47:17 -0500

berak gravatar image

updated 2017-09-01 01:04:08 -0500

imho, you don't need the -ts option, and you should not use it.

assuming, that normal and anomaly are your responses, you're already covered by the -r=0 (default) option (1st row has responses).

IF on the other hand, your 1st column are NOT responses, but categorical values, you'd have to use:


see here for a closer explanation

(note, that you have to use: -token=value with the CommandLineParser, the = is important !!)

edit flag offensive delete link more


Thanks for your answer.I thought i probably understood the difference between cat and ord. Then i tried to type 『rt.exe 15.csv -ts cat[0]』in cmdline, it happened:

OpenCV Error: Bad argument (type of some variables is not specified) in cv::ml::TrainDataImpl::setVarTypes, file C:\builds\master_PackSlave-win64-vc12-shared\opencv\modules\ml\src\data.cpp, line 741

I have no idea why it caused...

DowYuu gravatar imageDowYuu ( 2017-09-01 03:37:30 -0500 )edit

again, you have no categorial variables, they're all ordinal (and the = in the param is REALLY nessecary)

just use: tree_engine my.csv

berak gravatar imageberak ( 2017-09-01 03:46:07 -0500 )edit

It works!!! Thanks a lot!!!

DowYuu gravatar imageDowYuu ( 2017-09-01 04:09:32 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2017-08-31 23:09:25 -0500

Seen: 627 times

Last updated: Sep 01 '17