Randomly split data set and make sure that a sample of each class is included

4 vues (au cours des 30 derniers jours)
Hello,
I am randomly splitting my dataset into train,validation and test sets as shown below:
% Random split Complete Data Set
Q = size(completeRDS,1);
Q1 = floor(Q*0.75);
Q2 = Q-Q1;
Q2 = round(Q2/2);
Q3 = Q2;
ind = randperm(Q);
ind1 = ind(1:Q1);
ind2 = ind(Q1+(1:Q2));
ind3 = ind(Q2+(1:Q3));
% Complete Data Set
trainData = completeRDS(ind1,1);
trainSeqLabels = seqLabels(ind1,1);
valData = completeRDS(ind3,1);
valLabels = seqLabels(ind3,1);
testData = completeRDS(ind2,1);
testLabels = seqLabels(ind2,1);
I have just realised that my test set has not included a sample from each class that I am trying to classify. It has not included 2 of the classes
How can i split my data set and make sure that the test set includes at least 1 sample of each class that i am trying to classify?
Thanks in advance

Réponses (1)

MaryD
MaryD le 8 Jan 2020
If those are images I think best way is to load your data with class labels and then use splitEachLabel( __,'randomize') function.
  1 commentaire
CHRISTOPHER MILLAR
CHRISTOPHER MILLAR le 8 Jan 2020
It is EMG signal data so i dont think this function will work
Thanks for your answer though

Connectez-vous pour commenter.

Catégories

En savoir plus sur Image Data Workflows dans Help Center et File Exchange

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by