张展鹏,20210240045
2021年5月29日
iris.dat
混合了输入数据集和输出答案,我做了解析,分离了二者。
请注意,因为输入数据被预先洗乱以及随机化方法被使用,所以中间结果存在少许波动。
错误率是稳定的。
(5.825100, 3.009156, 3.810974, 1.190100)
(5.838064, 3.051959, 3.734742, 1.192877)
(5.831263, 3.114359, 3.669225, 1.190287)
80
因为我的输入是随机生成的,另外,样本数目高达150,所以不在这里详细列出了。
我打印了随机化输入的样本->聚类对应关系,请验证。
上列随机化样本的聚类结果是:
0 2
1 0
2 1
3 1
4 1
.. ..
145 1
146 0
147 1
148 2
149 0
类标签不跟输入一一对应,只反映相对分类关系。可以结合rank_table
验证。
聚类结果的类中心如下:
(6.775011, 3.052382, 5.646782, 2.053547)
(5.888932, 2.761069, 4.363952, 1.397315)
(5.003966, 3.414089, 1.482816, 0.253546)
16/150 = 10.67%
谱聚类结果见下列输出。输入数据未被预先洗乱,结果是稳定的。
(中间结果请在implement-spectral-clustering
分支运行源代码以获得)
错误率:
18/150 = 12.00%
$ python __main__.py
###### The shuffled input data frame is as follows: ######
0 1 2 3
0 5.7 2.9 4.2 1.3
1 6.4 3.2 4.5 1.5
2 7.6 3.0 6.6 2.1
3 6.1 3.0 4.9 1.8
4 4.7 3.2 1.3 0.2
.. ... ... ... ...
145 6.8 3.2 5.9 2.3
146 5.3 3.7 1.5 0.2
147 5.5 2.3 4.0 1.3
148 4.9 3.0 1.4 0.2
149 5.4 3.4 1.5 0.4
[150 rows x 4 columns]
##############################
###### Fuzzy Clustering ######
##############################
###### The randomly selected center points of the clusters are as follows: ######
0 1 2 3
0 5.817118 3.120257 3.575593 1.113203
1 5.800192 3.059543 3.641463 1.161313
2 5.921869 3.023435 4.004425 1.312133
###### After 81 iteration(s), the clustering results are as follows: ######
0
0 1
1 1
2 2
3 1
4 0
.. ..
145 2
146 0
147 1
148 0
149 0
[150 rows x 1 columns]
###### The center points of the clusters are as follows: ######
0 1 2 3
0 5.003966 3.414089 1.482816 0.253546
1 5.888932 2.761069 4.363952 1.397315
2 6.775011 3.052382 5.646782 2.053547
###### The clustering accuracy of fuzzy clustering is: ######
134/150 == 0.8933333333333333
#################################
###### Spectral Clustering ######
#################################
###### The result of spectral clustering is as follows: ######
0
0 0
1 0
2 0
3 0
4 0
.. ..
145 2
146 1
147 1
148 2
149 1
[150 rows x 1 columns]
###### The clustering accuracy of spectral clustering is: ######
132/150 == 0.88
2021年5月29日