Trining a neural network with leave one out crossval method
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello there,
I am new at neural networks and matlab. I am tring to train a network but i have less data available with me, so I am trying with leave-one-out method. But i am unable to find a way. Is there any direct method of training with leave-one-out training in matlab environment or what way should i follow. Thank you.
0 comentarios
Respuestas (1)
Jalaj Gambhir
el 25 de Feb. de 2020
Hi,
'Leave-one-out' is a cross validation method. You can generate cross validation indices for train and test set using cvpartition, specifying 'LeaveOut' parameter. This would generate partitions of n-1 training samples and 1 test sample.
>> load fisheriris;
>> x = meas;
>> y = species;
>> c = cvpartition(y,'LeaveOut')
This generates
c =
Leave-one-out cross validation partition
NumObservations: 150
NumTestSets: 150
TrainSize: 149 149 149 149 149 149 149 149 149 149 ...
TestSize: 1 1 1 1 1 1 1 1 1 1 ...
For each partition 'i', you can generate train and test samples as:
>> x_train = x(training(c,i),:);
>> y_train = y(training(c,i),:); % You might want to convert this to one-hot-encoded vectors
>> x_test = x(test(c,i),:);
>> y_test = y(test(c,2),:); % You might want to convert this to one-hot-encoded vectors
Then you can use this train and test data to train a neural network using tools like nnstart which are perfect for beginners. Look at an example here.
1 comentario
Juan Manuel Miguel
el 6 de Ag. de 2020
Thank you Jalaj, it was very useful for me. I think you meant y_test = y(test(c,i),:); instead of y_test = y(test(c,2),:); didn't you?
Thank you
Ver también
Categorías
Más información sobre Deep Learning Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!