split data to train,test and validation

16 visualizaciones (últimos 30 días)
REMYA K
REMYA K el 15 de Nov. de 2020
Comentada: Adam Danz el 16 de Nov. de 2020
I want to split my data into train and test in a ratio of 70:30,further I want to split my train data into train and validation in a ratio of 60:10. I want 5 folds of such train,test and validation data combination but test data should be same in all 5 folds.
How can I solve this ?
Can any one help me.

Respuestas (1)

Adam Danz
Adam Danz el 15 de Nov. de 2020
If you have the Statistics and Machine Learning toolbox, use cvpartition.
Otherwise, randperm to create indicies that separate the test and training sets.
  2 comentarios
Fathima Bareeda
Fathima Bareeda el 16 de Nov. de 2020
How can i solve this using randperm
Adam Danz
Adam Danz el 16 de Nov. de 2020
For example, let's say I want to split up vector "data" into 70/30 training/test sets.
data = rand(1,1000);
trainIdx = randperm(numel(data), round(numel(data)*.7));
testIdx = find(~ismember(1:numel(data), trainIdx));
trainIdx and testIdx are indices of the 'data' vector without overlap. To confirm that,
isequal(sort([trainIdx,testIdx]), 1:numel(data))
ans = logical
1
The training set will roughly cover 70% while the test set will roughly cover 30%. To confirm that,
[numel(trainIdx)/numel(data), numel(testIdx)/numel(data)]
ans = 1×2
0.7000 0.3000

Iniciar sesión para comentar.

Categorías

Más información sobre Hypothesis Tests en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by