Does cvpartition work with structs?
3 ビュー (過去 30 日間)
古いコメントを表示
Brandon Carrier
2021 年 11 月 18 日
コメント済み: Walter Roberson
2021 年 11 月 18 日
I am trying to work with a dataset provided to me that is a struct. I want to use cvpartition() as to maintain the ratio of classes in the resulting train and test sets, otherwise I would use randperm(). Here is the code I am trying to run:
% Struct is Messages
% "label" is the field containing the classes I want to sort by
c = cvpartition(Messages.label,'Holdout',1/3);
testIndices=test(c);
trainIndices=training(c);
trainData=data(trainIndices,:);
testData=data(testIndices,:);
The following is the error I receive upon running:
Error using internal.stats.cvpartitionInMemoryImpl (line 71)
CVPARTITION can have at most two optional arguments
Error in cvpartition (line 175)
cv.Impl = internal.stats.cvpartitionInMemoryImpl(varargin{:});
Error in scratch_script (line 8)
c = cvpartition(Messages.label,'Holdout',1/3);
Any guidance here would be appreciated. Thanks in advance!
0 件のコメント
採用された回答
Walter Roberson
2021 年 11 月 18 日
c = cvpartition({Messages.label}, 'Holdout', 1/3);
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Linear Regression についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
