Ask Your Question
0

std::length_error at Ptr<cv::ml::DTrees> train

asked 2016-11-14 14:19:04 -0600

DerrickB gravatar image

Hello Open CV Community,

i try to train my Decision Tree but always get the same Error:

Unhandled exception at 0x00007FFC34287788 in DecisionTrees.exe: Microsoft C++ exception: std::length_error at memory location 0x0000004ECC0FF560.

The Error comes with the 3. Line. No Matter whats in the "Feature" or "Labels" Matrix. (I tried it even with just 0 and 1)

Ptr<cv::ml::DTrees> model = cv::ml::DTrees::create();

Ptr<cv::ml::TrainData> myTrainData = cv::ml::TrainData::create(Features, cv::ml::ROW_SAMPLE, Labels);

model->train(myTrainData);

Do somebody know how to handle this error?

Thanks a lot for your support!

Kind regards, Derrick

edit retag flag offensive close merge delete

Comments

@berak i created a new question for my problem, i hope you can help. Thank you.

DerrickB gravatar imageDerrickB ( 2016-11-14 14:19:58 -0600 )edit
LBerger gravatar imageLBerger ( 2016-11-14 14:23:40 -0600 )edit
1

i can reproduce it (that's a good start !)

berak gravatar imageberak ( 2016-11-15 01:58:12 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2016-11-15 02:14:07 -0600

berak gravatar image

this might be a minor bug, the default params for the DTree just don't work. try:

Ptr<cv::ml::DTrees> model = cv::ml::DTrees::create();

model->setMaxDepth(10);
model->setMinSampleCount(2);
model->setCVFolds(0);

bool ok = model->train(myTrainData);
edit flag offensive delete link more

Comments

also, be careful, the other "Tree" variants suffer from similar problems !

berak gravatar imageberak ( 2016-11-15 04:23:15 -0600 )edit
1

new source file for machine learning @philipp-wagner

LBerger gravatar imageLBerger ( 2016-11-15 12:16:24 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-11-14 14:19:04 -0600

Seen: 496 times

Last updated: Nov 15 '16