How to create indices for the k-fold cross-validation?
古いコメントを表示
Hi All,
I'd like to create indices for the k-fold cross-validation using
indices = crossvalind('Kfold',Labels,k);
The "Labels" is a 1-by-1000 cell array which contains 1000 cells, as follows
Labels(1: 10) = 1×10 cell array
Columns 1 through 9
{1×1 cell} {1×1 cell} {1×1 cell} {1×1 cell} {1×1 cell} {1×1 cell} {1×1 cell} {1×1 cell} {1×1 cell}
Column 10
{1×1 cell}
Labels{1}= 1×1 cell array
{'2'}
I got this error
Undefined function 'crossvalind' for input arguments of type 'cell'.
So, I took the following steps to solve the issue
Label_1 = cellfun(@(x) str2double(x), Labels, 'UniformOutput',false);
Label_double = [Label_1{:}]
indices = crossvalind('Kfold',Label_double,10);
And now I am dealing with the following error
Undefined function 'crossvalind' for input arguments of type 'char'.
I'm not sure why I get this error. any idea? Thanks!
3 件のコメント
Susan
2021 年 6 月 8 日
Megumi Fukuda
2021 年 6 月 9 日
Could you upload your label variable (you can upload .mat file) so that I can have a look? I assume your label is what-I-call 'nested' and that's why you cannot use crossvalind.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Import Data についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!