how to partition data into testing and training

19 Ansichten (letzte 30 Tage)
Lucrezia Cester
Lucrezia Cester am 7 Feb. 2021
Bearbeitet: Ive J am 7 Feb. 2021
Hello,
I am trying to train a ML network. I am using a matlab function which partitions my data into training and testing set. The problem is that since the classes are arranged likee so:
data=[a a a a a a a a a a a b b b b b b b b b b b c c c c c c c c c c c ] (the a b c in place of the actual classes]
when I use the partition function i get
training [ a a a a a a a b b b b b b b c c c c c c c ]
testing [ a a a a b b b b c c c c ]
while I would want the data to be mized as such :
training [ a b b c b a ...etc
testing [ c b a a /...etc
is there a function to achieve these random splitting?
Thank you very much.

Antworten (1)

Ive J
Ive J am 7 Feb. 2021
Bearbeitet: Ive J am 7 Feb. 2021
While I don't see any issues with what MATLAB does nor understand your point, you can use something like this:
test_idx = randperm(numel(data), round(numel(data)*.2)); % 20% for test
train_idx = setdiff(1:numel(data), test_idx); % remaining for training

Kategorien

Mehr zu Testing Frameworks finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by