我对下面的代码有一个小问题,最后一行是具体的,我试图找到我的“样本”的类名,我的意思是我需要知道哪个法线和哪个蓝精灵属于我的 1000x6 样本的每一行。
%% sampling
normIdx = strmatch('normal.', Book2);
normalSubset = fulldata(normIdx, :);
normal = randperm(size(normalSubset , 1));
p = (normal(1:750)-1)';
%
smurfIdx = strmatch('smurf.', Book2);
smurfSubset = fulldata(smurfIdx, :);
smurf = randperm(size(smurfSubset , 1));
a = (smurf(1:250)-1)';
%
normalSample = normalSubset (p, :);
smurfSample = smurfSubset (a, :);
%
sample = [normalSample ; smurfSample]
%
sample = sample(randperm(1000),:);
%
idx = [a ; p];
K1 = Book2(idx (sample==1), :)
K1 应等于 1000 个样本类标签,其中 750 个为正常标签,250 个为蓝标签,并且它们应与样本中的同一行完全对应。 Book2 包含类标签,我也有从中派生示例的完整数据。
Atm K1 结果:
Index exceeds matrix dimensions
可能有一种简单的方法将样本数据与完整数据中的数据进行匹配,但我不确定完整数据中是否可能存在重复数据......所以匹配已经结束,因为sample
是随机的,所以我不知道如何将类标签与采样相匹配。
你是这个意思吗? :
%
shuffle = randperm(1000);
sample = sample(shuffle,:);
%
idx = [a ; p];
K1 = Book2(idx (shuffle), :);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)