How to split an image datastore for cross-validation?

조회 수: 4 (최근 30일)
Elena Ranguelova
Elena Ranguelova 2017년 2월 10일
댓글: Sajja Tulasi Krishna 2021년 2월 22일
Hello,
The method
splitEachLabel
of an
imageDatastore
object splits an image data store into proportions per category label. How can one split an image data store for training using cross-validation and using the
trainImageCategoryCalssifier
class?
I.e. it's easy to split it in N partitions, but then some sort of mergeEachLabel functionality is needed to be able to train a classifier using cross-validation. Or is there another way of achieving that?
Regards, Elena
  댓글 수: 2
kowshik Thopalli
kowshik Thopalli 2017년 2월 26일
I am looking for an answer to a similar problem. Did you solve it?
Tripoli Settou
Tripoli Settou 2018년 4월 19일
I am also looking for an answer to a similar problem. Did you solve it?

댓글을 달려면 로그인하십시오.

채택된 답변

Hamza Mehboob
Hamza Mehboob 2018년 7월 27일
[imd1 imd2 imd3 imd4 imd5 imd6 imd7 imd8 imd9 imd10] = splitEachLabel(imds,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,'randomize');
partStores{1} = imd1.Files ;
partStores{2} = imd2.Files ;
partStores{3} = imd3.Files ;
partStores{4} = imd4.Files ;
partStores{5} = imd5.Files ;
partStores{6} = imd6.Files ;
partStores{7} = imd7.Files ;
partStores{8} = imd8.Files ;
partStores{9} = imd9.Files ;
partStores{10} = imd10.Files;
for i = 1 :k
i
test_idx = (idx == i);
train_idx = ~test_idx;
imdsTest = imageDatastore(partStores{test_idx}, 'IncludeSubfolders', true,'FileExtensions','.jpeg', 'LabelSource', 'foldernames');
imdsTrain = imageDatastore(cat(1, partStores{train_idx}), 'IncludeSubfolders', true,'FileExtensions','.jpeg', 'LabelSource', 'foldernames');
%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%Write your classification task
%%%%hamzamehboob103@gmail.com for any further help.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
}
  댓글 수: 4
TRIPTI GOEL
TRIPTI GOEL 2020년 6월 5일
thank you for the code.
Sajja Tulasi Krishna
Sajja Tulasi Krishna 2021년 2월 22일
Thanq for clear doubt @Hamza Mehboob

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Datastore에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by