2012-11-21 38 views
0

下面是我的採樣數據,10%的方法:數據集減去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), :); 

我不知道我怎麼會那麼從數據集(cluster2)移除這個10%?請注意,當我說10%,我已經完成了這一點,因此(探針(1:71)這是探針類的10%等

+0

有沒有如何完成TestData?不知道我如何獲得TestData的索引,但希望在所有方法中使用? –

+0

Where do 'normalSample'等是從哪裏來的? – Junuxx

+0

Ah soz錯過了代碼中的那一點,用樣本子集更新了問題。 –

回答

2

如果我理解正確,你有一個索引矢量idx包含所有。要保存行

在這種情況下,解決辦法很簡單,刪除他們,你可以遵循@ H.Munster指示的方法,但用正確的指標:

cluster2(idx, :) = [];