Index in position 2 exceeds array bounds (must not exceed 1).
4 ビュー (過去 30 日間)
古いコメントを表示
load featurs_T
load featurs_S
load Group_Train
load Group_Test
load actual_label
load predict_label
load predict_label
%WEIGHTEDVOTING is a proposed ensemble method
k = max(actual_label); % determining number of classes [1-K]
heus = [];
%HOG_SVM = multisvm(Feat1,Group_Train1,Feat2,Group_Test1);
rec = recall(predict_label, actual_label); prec = precision(predict_label, actual_label);
heus = [heus; 2*f1(prec,rec)-FPR(predict_label, actual_label)];
%LBP_SVM = multisvm(Feat1,Group_Train1,Feat2,Group_Test1);
rec = recall(predict_label2, actual_label); prec = precision(predict_label2, actual_label);
heus = [heus; 2*f1(prec,rec)-FPR(predict_label2, actual_label)];
res = zeros(length(actual_label),length(k));
for i=1:length(actual_label)
res(i,predict_label(i)) = res(i,predict_label(i)) + heus(1);
res(i,predict_label2(i)) = res(i,predict_label2(i)) + heus(2);
end
[~, preds] = max(res,[],2);
Index in position 2 exceeds array bounds (must not exceed 1).
Error in weightedVoting (line 27)
res(i,predict_label(i)) = res(i,predict_label(i)) + heus(1);
0 件のコメント
採用された回答
KSSV
2022 年 5 月 29 日
This is a simple error. You are trying to extract more number of elements then present in the array.
% Example
A = rand(1,5) ; % size of A is 1x5
A(1) % no error
A(4) % no error
A(end) % no error, this will give you 5th element
A(6) % error, there is no 6th element
Like wise check the dimensions of each array and use looping.
0 件のコメント
その他の回答 (2 件)
Walter Roberson
2022 年 5 月 29 日
A predicted label might exceed the number of actual labels.
Or heus might be empty, if some of the other variables are empty.
3 件のコメント
Walter Roberson
2022 年 5 月 29 日
k is the maximum label, which is a scalar. length(k) is 1. You use length(k) as the upper bound for the size of res so res is 120 by 1 instead of 120 by the number of labels
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!