在下面的示例中,我似乎无法从fulldata获取UnseenTestdata和Testdata的索引,有人可以帮忙吗?
pointsToPick = 49402; %# Numbers to pick
rVec = randperm(494021); %# Random permutation of datapoint indices (N=494021 in this case)
UnseenTestdata = fulldata(rVec(1:pointsToPick),:); %# Random sample
Testdata = fulldata(rVec((pointsToPick+1):length(rVec)),:);
我需要有一个来自fulldata的行号的列表,unseentestdata来自和testdata相同。这与先前的问题here有关,没有索引我无法弄清楚哪些类标签与unseentestdata和testdata一起使用。
答案 0 :(得分:1)
如果你不想使用已存储索引的rVec(1:pointsToPick)
@Tobold说,另一种方式是
[~,indx_uns]=ismember(UnseenTestdata, fulldata, 'rows');
[~,indx_test]=ismember(Testdata, fulldata, 'rows');
请注意,未使用第一个返回参数(因此标记为~
)
indx_uns(n)
将相应的fulldata行提供给UnseenTestdata的第n行。
此外here is a link to the related SO question。
有关ismember的更多帮助:请参阅this link