Create all permutations of 1x13 vector used for Leave-p-out Cross-Validation

3 次查看(过去 30 天)
Hi,
I am trying to develop a sound quality metric and for that I need to find all possible combination of my vector A=[1:1:13] values to pick out 11 set for training and 2 sets for validation to later use the regress function. Perms(A) is to large to be used and I can't use nchoosek(A,13). I want to creata a matrice which is 13x78 since that should be all possible permutation.
Any ideas?
If you need better clarifications please let me know.

回答(1 个)

Akira Agata
Akira Agata 2022-2-23
How about the following?
Though this generates 78x11 (instead of 13x78 which you expected), the result contains all possible combination.
% Create all possible combination of 11 elements out ouf 1~13
comb = nchoosek(1:13, 11);
% Show the result
disp(comb)
1 2 3 4 5 6 7 8 9 10 11 1 2 3 4 5 6 7 8 9 10 12 1 2 3 4 5 6 7 8 9 10 13 1 2 3 4 5 6 7 8 9 11 12 1 2 3 4 5 6 7 8 9 11 13 1 2 3 4 5 6 7 8 9 12 13 1 2 3 4 5 6 7 8 10 11 12 1 2 3 4 5 6 7 8 10 11 13 1 2 3 4 5 6 7 8 10 12 13 1 2 3 4 5 6 7 8 11 12 13 1 2 3 4 5 6 7 9 10 11 12 1 2 3 4 5 6 7 9 10 11 13 1 2 3 4 5 6 7 9 10 12 13 1 2 3 4 5 6 7 9 11 12 13 1 2 3 4 5 6 7 10 11 12 13 1 2 3 4 5 6 8 9 10 11 12 1 2 3 4 5 6 8 9 10 11 13 1 2 3 4 5 6 8 9 10 12 13 1 2 3 4 5 6 8 9 11 12 13 1 2 3 4 5 6 8 10 11 12 13 1 2 3 4 5 6 9 10 11 12 13 1 2 3 4 5 7 8 9 10 11 12 1 2 3 4 5 7 8 9 10 11 13 1 2 3 4 5 7 8 9 10 12 13 1 2 3 4 5 7 8 9 11 12 13 1 2 3 4 5 7 8 10 11 12 13 1 2 3 4 5 7 9 10 11 12 13 1 2 3 4 5 8 9 10 11 12 13 1 2 3 4 6 7 8 9 10 11 12 1 2 3 4 6 7 8 9 10 11 13 1 2 3 4 6 7 8 9 10 12 13 1 2 3 4 6 7 8 9 11 12 13 1 2 3 4 6 7 8 10 11 12 13 1 2 3 4 6 7 9 10 11 12 13 1 2 3 4 6 8 9 10 11 12 13 1 2 3 4 7 8 9 10 11 12 13 1 2 3 5 6 7 8 9 10 11 12 1 2 3 5 6 7 8 9 10 11 13 1 2 3 5 6 7 8 9 10 12 13 1 2 3 5 6 7 8 9 11 12 13 1 2 3 5 6 7 8 10 11 12 13 1 2 3 5 6 7 9 10 11 12 13 1 2 3 5 6 8 9 10 11 12 13 1 2 3 5 7 8 9 10 11 12 13 1 2 3 6 7 8 9 10 11 12 13 1 2 4 5 6 7 8 9 10 11 12 1 2 4 5 6 7 8 9 10 11 13 1 2 4 5 6 7 8 9 10 12 13 1 2 4 5 6 7 8 9 11 12 13 1 2 4 5 6 7 8 10 11 12 13 1 2 4 5 6 7 9 10 11 12 13 1 2 4 5 6 8 9 10 11 12 13 1 2 4 5 7 8 9 10 11 12 13 1 2 4 6 7 8 9 10 11 12 13 1 2 5 6 7 8 9 10 11 12 13 1 3 4 5 6 7 8 9 10 11 12 1 3 4 5 6 7 8 9 10 11 13 1 3 4 5 6 7 8 9 10 12 13 1 3 4 5 6 7 8 9 11 12 13 1 3 4 5 6 7 8 10 11 12 13 1 3 4 5 6 7 9 10 11 12 13 1 3 4 5 6 8 9 10 11 12 13 1 3 4 5 7 8 9 10 11 12 13 1 3 4 6 7 8 9 10 11 12 13 1 3 5 6 7 8 9 10 11 12 13 1 4 5 6 7 8 9 10 11 12 13 2 3 4 5 6 7 8 9 10 11 12 2 3 4 5 6 7 8 9 10 11 13 2 3 4 5 6 7 8 9 10 12 13 2 3 4 5 6 7 8 9 11 12 13 2 3 4 5 6 7 8 10 11 12 13 2 3 4 5 6 7 9 10 11 12 13 2 3 4 5 6 8 9 10 11 12 13 2 3 4 5 7 8 9 10 11 12 13 2 3 4 6 7 8 9 10 11 12 13 2 3 5 6 7 8 9 10 11 12 13 2 4 5 6 7 8 9 10 11 12 13 3 4 5 6 7 8 9 10 11 12 13
  3 个评论
Akira Agata
Akira Agata 2022-2-23
Well, I believe the following will work:
% For training (78x11)
combTrain = nchoosek(1:13, 11);
% For validation (78x2)
combValidation = arrayfun(@(k) setdiff(1:13,combTrain(k,:)), 1:78,...
'UniformOutput', false);
combValidation = cell2mat(combValidation');
Filip Wadman
Filip Wadman 2022-2-23
This worked very well. Thank you!
Now the next questions arises. For my vector A=1:13 we had another vector B=1:13 with values corresponding to each value in vector A which I now need to use with the regress function regress(A,B). Is it possible to find which element in my B vector which belongs to my new combTrain that we have created?
When I run my regress functions now it complains that the arrays don't match which is obvoius but to run it I need the right values from B belonging to A to receive a correct result.

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by