필터 지우기
필터 지우기

use of train and test data

조회 수: 6 (최근 30일)
Elahe Karimi
Elahe Karimi 2019년 5월 18일
편집: Elahe Karimi 2019년 5월 18일
hello,
I've used this code to separate data to test and train .for example i have a dataset include of 6 image. when i run this code, training data is correct and have 3 image but testing data is like this image :(The third image is repeated again).
I can't understand what is the problem .
Please help me
thank you
idx = 1:numImageFiles ;
PTrain = 0.50 ;
Ptest = 0.50;
train_idx = baseFileNames(1:round(PTrain*numImageFiles)); % training indices
test_idx = baseFileNames(round(Ptest*numImageFiles):end,:) ; %test

채택된 답변

Walter Roberson
Walter Roberson 2019년 5월 18일
You use round(PTrain*numImageFiles) as the upper limit for train_idx, and you use the same round(PTrain*numImageFiles) as the lower limit for test_idx . That is going to include round(PTrain*numImageFiles) exactly in both train_idx and test_idx .
  댓글 수: 3
Walter Roberson
Walter Roberson 2019년 5월 18일
The round is not the problem. Consider you are doing the equivalent of
x(1:3) %index 1, 2, 3
x(3:6) %index 3, 4, 5, 6
When your first range ends at N, then your second range needs to start from at least one greater than N or else you will have overlap.
Elahe Karimi
Elahe Karimi 2019년 5월 18일
편집: Elahe Karimi 2019년 5월 18일
ok,I understood. Thank you very much for response.
round(Ptest*numImageFiles)+1

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Pattern Recognition and Classification에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by