以下是对我的 10% 数据进行采样的方法:
%%
% Normal
normIdx = strmatch('normal.', K2);
normalSubset = cluster2(normIdx, :);
normal = randperm(size(normalSubset , 1));
p = (normal(1:3495))';
%% DoS
DoSIdx = strmatch('DoS', K2);
DoSSubset = cluster2(DoSIdx, :);
DoS = randperm(size(DoSSubset , 1));
a = (DoS(1:8))';
%%
ProbeIdx = strmatch('Probe', K2);
ProbeSubset = cluster2(ProbeIdx, :);
Probe = randperm(size(ProbeSubset , 1));
d = (Probe(1:71))';
%%
normalSample = normalSubset (p, :);
%%
DoSSample = DoSSubset (a, :);
%%
ProbeSample = ProbeSubset (d, :);
%%
idx = [normIdx(p);DoSIdx(a);ProbeIdx(d)];
%
sample = [normalSample ; DoSSample ; ProbeSample]
%
shuffle = randperm(3574);
%
TestData = sample(shuffle,:);
%
TestDataLabels = K2(idx (shuffle), :);
我想知道如何才能从数据集中删除这 10% ( cluster2
)?请注意,当我说 10% 时,我已经解决了这个问题,因此 (Probe(1:71) 这是探测类的 10% 等