First time here? Check out the FAQ!

Ask Your Question
0

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

asked Nov 14 '16

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

Preview: (hide)

Comments

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

DerrickB gravatar imageDerrickB (Nov 14 '16)edit
1

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

berak gravatar imageberak (Nov 15 '16)edit

1 answer

Sort by » oldest newest most voted
2

answered Nov 15 '16

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);
Preview: (hide)

Comments

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

berak gravatar imageberak (Nov 15 '16)edit
1

new source file for machine learning @philipp-wagner

LBerger gravatar imageLBerger (Nov 15 '16)edit

Question Tools

1 follower

Stats

Asked: Nov 14 '16

Seen: 508 times

Last updated: Nov 15 '16