Ask Your Question
0

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

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

DowYuu gravatar image

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

berak gravatar image

Hi Everyone

I am using https://github.com/opencv/opencv/blob...

and there is a little part of my data :

normal,0,31,29,78,1,0,0,0,4

normal,0,31,29,82,1,0,0,0,2

anomaly,2,254,0,0,1,0,0,0,0

anomaly,1,254,252,45,1,0.048129,1,1,6

normal,0,31,29,82,1,0,0,0,2

anomaly,1,254,252,45,1,0.046134,0,0,6

anomaly,1,254,252,45,1,0.044321,1,1,6

normal,0,31,29,82,1,0,0,0,2

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

Comments

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

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

1 answer

Sort by » oldest newest most voted
0

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

berak gravatar image

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

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:

-ts=cat[0]

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

Comments

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 -0600 )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 -0600 )edit
1

It works!!! Thanks a lot!!!

DowYuu gravatar imageDowYuu ( 2017-09-01 04:09:32 -0600 )edit

Question Tools

1 follower

Stats

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

Seen: 1,043 times

Last updated: Sep 01 '17