因此,我正处于下一步该做什么的十字路口,我开始学习一些机器学习算法并将其应用于复杂的数据集,现在我已经做到了。我从一开始的计划就是结合两种可能的分类器,试图建立一个多分类系统。
但这就是我被困住的地方。我选择聚类算法(模糊 C 均值)(在学习了一些示例 K 均值之后)和朴素贝叶斯作为 MCS(多分类器系统)的两个候选算法。
我可以独立使用两者来对数据进行分类,但我正在努力以有意义的方式将两者结合起来。
例如,模糊聚类捕获了几乎所有“Smurf”攻击,除了通常的攻击之外。one我不知道为什么它没有抓住这个odd ball但我只知道事实并非如此。其中一个集群将受到蓝精灵攻击的主导,通常我只会在其他集群中找到一个蓝精灵。这就是我遇到问题场景的地方,如果我在所有不同的攻击类型(蓝精灵、正常、海王星...等)上训练贝叶斯分类器,并将其应用于其余的集群,试图找到最后一个剩下的smurf将会有很高的误报率。
我不知道如何继续,我不想将其他攻击从训练集中剔除,但我只想训练贝叶斯分类器来发现“蓝精灵”攻击。目前,它被训练来尝试发现一切,在这个过程中,我认为(不确定)准确性会下降。
所以这是我在使用朴素贝叶斯分类器时的问题,如何让它只查找蓝精灵并将其他所有内容分类为“其他”。
rows = 1000;
columns = 6;
indX = randperm( size(fulldata,1) );
indX = indX(1:rows)';
data = fulldata(indX, indY)
indX1 = randperm( size(fulldata,1) );
indX1 = indX1(1:rows)';
%% apply normalization method to every cell
%data = zscore(data);
training_data = data;
target_class = labels(indX,:)
class = classify(test_data,training_data, target_class, 'diaglinear')
confusionmat(target_class,class)
我的想法是手动更改target_class
来自所有正常流量和非 Smurf 的攻击other。然后,由于我已经知道 FCM 可以正确分类除一次 smurf 攻击之外的所有攻击,因此我只需对其余集群使用朴素贝叶斯分类器即可。
例如:
集群 1 = 500 次蓝精灵攻击(重复此步骤可能会将“大多数”smurf 攻击从 1000 个样本转移到不同的集群中,因此我必须检查或迭代集群以获得最大尺寸,一旦找到,我可以将其从朴素贝叶斯分类器阶段中删除)
然后我在每个剩余的集群上测试分类器(不确定如何在 matlab 中执行循环等),所以目前我必须在处理过程中手动选择它们。
clusters = 4;
CM = colormap(jet(clusters));
options(1) = 12.0;
options(2) = 1000;
options(3) = 1e-10;
options(4) = 0;
[~,y] = max(U);
[centers, U, objFun] = fcm(data, clusters, options); % cluster 1000 sample data rows
training_data = newTrainingData(indX1,indY); % this is the numeric data
test_data = fulldata(indX(y==2),:); % this is cluster 2 from the FCM phase which will be classified.
test_class = labels(indX(y==2),:); % thanks to amro this helps the confusion matrix give an unbiased error detection rate in the confusion matrix.
target_class = labels(indX,:) % this is labels for the training_data, it only contains the smurf attacks while everything else is classed as other
class = classify(test_data,training_data, target_class, 'diaglinear')
confusionmat(test_class,class)
然后,我对剩余的每个集群重复贝叶斯分类器,寻找一次蓝精灵攻击。
我的问题是,如果它将“其他”攻击错误分类为蓝精灵或找不到剩余的蓝精灵,会发生什么。
我感觉有点迷失了更好的方法。我正在尝试选择蓝精灵攻击与“其他”的良好比率,因为我不想过度拟合,这在上一个问题中已解释过here https://stackoverflow.com/questions/11554938/naive-classifier-matlab.
但这需要我一些时间,因为我还不知道如何将现有标签从 neptune、back、ipsweep、wareclient 攻击更改/替换为 matlab 中的“其他”,所以我还无法测试这个理论(将到达那里) 。
所以我的问题是:
1) 是否有更好的方法来发现难以捉摸的蓝精灵攻击。
2)我怎样才能grep target_class(标签)来替换所有不是smurf的东西“other"