how to partition data into testing and training
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
0 commentaires
Réponses (1)
Ive J
le 7 Fév 2021
Modifié(e) : Ive J
le 7 Fév 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
0 commentaires
Voir également
Catégories
En savoir plus sur Statistics and Machine Learning Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!