Ask Your Question

How to get a random subset of Mat ?

asked 2018-01-23 08:02:17 -0500

teenvan95 gravatar image

I have a data and label Mat object and at each iteration, I need to generate a random subset of the data and labels. How should I do this?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2018-01-23 08:13:13 -0500

LBerger gravatar image

updated 2018-01-23 08:17:34 -0500

You can use TrainData classes. First create an object TrainData :

Ptr<ml::traindata> t=ml::TrainData::create(data, ROW_SAMPLE, label);

theh you use SetTrainTestSplitRatio to shuffle data. You can get test data and train data using getTestSample or getTrainSamples method

You can read this example too

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2018-01-23 08:02:17 -0500

Seen: 346 times

Last updated: Jan 23 '18