【发布时间】:2011-12-04 16:17:32
【问题描述】:
我正在尝试从 KDD 1999 杯数据集中收集一些数据
文件的输出如下所示:
0,tcp,http,SF,239,486,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,8,8,0.00,0.00,0.00,0.00,1.00,0.00,0.00,19,19,1.00,0.00,0.05,0.00,0.00,0.00,0.00,0.00,normal.
有 48,000 条该格式的不同记录。我已经清理了数据并删除了仅保留数字的文本。现在的输出如下所示:
我在 excel 中创建了一个逗号分隔文件并保存为 csv 文件,然后从 matlab 中的 csv 文件创建了一个数据源,我尝试通过 matlab 中的 fcm 工具箱运行它(findcluster 输出 38 种数据类型,预计为 38列)。
但是,集群看起来不像集群,或者它不接受和按我需要的方式工作。
谁能帮忙找到这些集群?我是 matlab 新手,所以没有任何经验,我也是集群新手。
方法:
- 选择的簇数 (K)
- 初始化质心(从数据集中随机选择 K 个模式)
- 将每个模式分配给质心最近的集群
- 计算每个聚类的均值作为其新质心
- 重复第 3 步,直到满足停止条件(没有模式移动到另一个集群)
这就是我想要实现的目标:
这就是我得到的:
load kddcup1.dat
plot(kddcup1(:,1),kddcup1(:,2),'o')
[center,U,objFcn] = fcm(kddcup1,2);
Iteration count = 1, obj. fcn = 253224062681230720.000000
Iteration count = 2, obj. fcn = 241493132059137410.000000
Iteration count = 3, obj. fcn = 241484544542298110.000000
Iteration count = 4, obj. fcn = 241439204971005280.000000
Iteration count = 5, obj. fcn = 241090628742523840.000000
Iteration count = 6, obj. fcn = 239363408546874750.000000
Iteration count = 7, obj. fcn = 238580863900727680.000000
Iteration count = 8, obj. fcn = 238346826370420990.000000
Iteration count = 9, obj. fcn = 237617756429912510.000000
Iteration count = 10, obj. fcn = 226364785036628320.000000
Iteration count = 11, obj. fcn = 94590774984961184.000000
Iteration count = 12, obj. fcn = 2220521449216102.500000
Iteration count = 13, obj. fcn = 2220521273191876.200000
Iteration count = 14, obj. fcn = 2220521273191876.700000
Iteration count = 15, obj. fcn = 2220521273191876.700000
figure
plot(objFcn)
title('Objective Function Values')
xlabel('Iteration Count')
ylabel('Objective Function Value')
maxU = max(U);
index1 = find(U(1, :) == maxU);
index2 = find(U(2, :) == maxU);
figure
line(kddcup1(index1, 1), kddcup1(index1, 2), 'linestyle',...
'none','marker', 'o','color','g');
line(kddcup1(index2,1),kddcup1(index2,2),'linestyle',...
'none','marker', 'x','color','r');
hold on
plot(center(1,1),center(1,2),'ko','markersize',15,'LineWidth',2)
plot(center(2,1),center(2,2),'kx','markersize',15,'LineWidth',2)
【问题讨论】:
-
真的不知道我做错了什么?
-
能否包含生成集群的代码部分?
-
为什么用“C#”标记?
标签: matlab machine-learning cluster-analysis data-mining fuzzy