Ask Your Question
1

How to get a random subset of Mat ?

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

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
4

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

LBerger gravatar image

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

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

Stats

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

Seen: 631 times

Last updated: Jan 23 '18