Trining a neural network with leave one out crossval method

12 ビュー (過去 30 日間)
Basavraj Hadare
Basavraj Hadare 2020 年 2 月 22 日
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.

回答 (1 件)

Jalaj Gambhir
Jalaj Gambhir 2020 年 2 月 25 日
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 件のコメント
Juan Manuel Miguel
Juan Manuel Miguel 2020 年 8 月 6 日
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

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeModel Building and Assessment についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by