Académique Documents
Professionnel Documents
Culture Documents
Professor
Student
Student ID
: Wen-June Wang
: Wahyu Rahmaniar
: 102521604
Do the Exercise (1) if your student number is odd (except 5), Do the Exercise (2) if
your student number is even (except 0); Do the Exercise (3) if your student number is 0
or 5.
Exercise (1). Please classify 100 points in (a, b) space to 6 clusters, where the 100
points are generated from random Generator in Matlab and -30<a<30, 0<b<30.
Exercise (2). Please classify 100 points in (a, b) space to 5 clusters, where the 100
points are generated from random Generator in Matlab and -20<a<10, -15<b<20.
Exercise (3). Please classify 100 points in (a, b) space to 4 clusters, where the 100
points are generated from random Generator in Matlab and 10<a<20, 10<b<40.
Your report should contain the program, and statements explanation, a figure with 100
points, and a figure with clusters and 100 points. Furthermore, a discussion and a
conclusion.
1.Center of gravity : vi
(
k 1
(
k 1
2.Update of membership :
) xk
( p) m
ik
ik
ik( p 1)
c xk vi( p ) m21
(
)
( p)
j 1 xk v j
3. Cost function =
,1 i c
( p) m
J m (U ,V ) ( ik ) m xk vi
k 1 i 1
(2) 100 data points and their plot locations in the X-Y space
Table 1. Initial Point of 100 Randomly Generated
n-points
0
10
20
30
40
50
60
70
80
90
x
y
x
y
x
y
x
y
x
y
x
y
x
y
x
y
x
y
x
y
1+n
2+n
3+n
4+n
5+n
6+n
7+n
8+n
9+n
10+n
-11.107
-7.591
-5.607
-19.568
7.1623
1.2108
5.506
-14.957
3.308
2.503
5.949
-13.048
-8.047
-12.387
7.0693
13.476
18.585
3.1903
15.257
2.0514
-15.978
-12.689
-9.0718
-17.106
4.962
-11.718
-2.174
6.4787
-6.717
9.008
3.933
8.874
-5.1907
-4.0398
19.0057
3.609
-4.165
0.3103
12.644
-7.691
-16.154
-1.937
-7.554
-1.264
-1.9009
7.952
-3.657
-14.9202
-9.0163
7.579
-12.153
12.134
2.439
6.8405
-9.3511
-1.0107
3.4788
5.768
-2.783
-11.848
-10.061
6.833
1.877
5.196
-11.538
4.384
-11.736
-9.111
-0.0468
-6.517
0.105
-1.4995
7.7006
-7.826
-6.4293
16.632
18.3062
-12.602
3.945
8.086
-3.7705
7.578
-15.281
-4.529
-3.829
-1.412
-7.0045
-19.1602
-15.586
1.277
-12.587
-10.756
-2.033
-5.4801
-0.0042
19.7513
-4.858
-12.6605
-0.413
7.446
-6.4116
-10.223
-6.663
-0.5503
-3.9607
-18.998
-12.115
-18.263
-15.654
9.098
-12.969
0.767
19.372
6.513
-1.5095
14.366
13.838
-13.457
-6.429
4.7709
-7.199
-1.341
7.572
-2.457
7.097
-10.903
-19.224
9.752
-3.012
0.201
-5.201
-12.37
-0.625
-2.927
6.143
12.304
-10.185
-10.513
11.393
8.984
-12.374
-12.017
1.784
5.0309
-18.456
-3.126
-15.612
6.553
2.907
-4.687
14.595
-7.0711
-3.308
-14.338
-4.237
-8.197
8.504
-7.662
19.165
12.057
-3.518
-15.969
-2.368
-10.138
7.978
-10.7019
5.974
-8.698
-9.231
0.5403
18.932
19.9508
12.211
-4.305
1.153
-3.392
-10.829
-9.778
-2.289
4.409
4.525
-10.342
-16.71
-1.7604
-1.5128
-3.3896
-3.0693
-5.9102
-10.901
-3.689
1.113
-9.5604
4.804
-14.495
-4.368
4.2602
-1.365
-7.308
-13.496
-1.466
0.2813
5+n
6+n
7+n
8+n
9+n 10+n
0.0309
0.0124
0.0863
0.0107
0.033
0.0277
0.1515
0.0438
0.8978
0.0216
0.7806
0.1222
0.0454
0.928
3 0.0062 0.06
0.1561
0.0997
0.0019
0.9503
0.018
0.0365
0.0366
0.0271
4 0.436
0.2447
0.7965
0.0256
0.0098
0.0157
0.8092
0.0167
0.0162
0.015
0.0438
0.0059
0.0995
0.0215
0.8683
0.001
0.0317
0.5036
0.0068
0.2926
0.0006
0.0273
0.0963
0.1262
2 0.1382 0.0712 0.1233 0.0112 0.0079 0.1233 0.0336 0.2774 0.0241 0.387
10
0.0185
0.8767
0.1225
0.8934
0.0119
0.1977
0.0045
0.6437
0.0429
0.1856
5 0.002
0.6646
0.0541
0.0373
0.3149
0.6493
0.2933
0.0599
0.0289
0.2085
1 0.916
0.1472
0.1562
0.8067
0.7031
0.0264
0.8298
0.5186
0.3999
0.0185
2 0.0245 0.0053 0.0254 0.0374 0.1197 0.7663 0.0011 0.0094 0.1467 0.4239
20
0.0173
0.0083
0.0198
0.0115
0.0008
0.1827
0.027
4 0.0568 0.071
0.1294
0.055
0.0163
0.0071
0.4223
0.196
0.2385
0.3345
5 0.0009 0.7418 0.0438 0.0091 0.1139 0.1712 0.1505 0.0488 0.0748 0.2922
30
0.091
0.5034
0.4738
0.8078
0.0039
0.0012
0.0278
0.3271
0.026
0.0034
0.1195
0.0003
0.5898
0.0101
0.0154
0.0116
0.0003
0.0259
0.0829
0.4772
0.0015
0.8587
0.0017
5 0.0085 0.4997 0.8556 0.9738 0.9975 0.2655 0.0764 0.0076 0.1758 0.0177
1 0.0276 0.0276 0.0915 0.0133 0.7433 0.081
40
0.028
0.0046
0.5791
0.0181
0.8112
0.2861
0.0191
3 0.9196 0.6055 0.0107 0.0037 0.0677 0.1947 0.7678 0.0414 0.1092 0.9326
4 0.0181 0.083
50
0.0278
0.0062
0.1952
0.0105
0.0061
0.0241
0.029
0.5
0.006
0.1322
0.0195
0.0061
1 0.055
0.0016
0.9443
0.7434
0.4691
0.0264
0.1423
0.1722
0.0215
0.4105
0.0229
0.0205
0.2596
0.0447
4 0.1953 0.01
0.2984
0.5787
0.1548
0.0394
0.4207
0.0143
0.0057
0.0029
0.1306
0.581
0.229
0.4455
0.2918
0.0556
0.2288
0.2076
0.1115
0.1735
0.0744
0.0227
2 0.0282 0.125
0.9783
0.4067
0.5582
0.5144
0.0997
0.09
0.3888
0.0233
0.9403
0.0435
0.0621
0.0044
0.0342
0.0008
0.0021
0.0506
0.8632
0.0002
0.8329
1 0.1259 0.0696 0.1357 0.4788 0.1341 0.0595 0.1132 0.0487 0.2059 0.1907
2 0.0599 0.0698 0.7308 0.241
70
0.4269
0.0924
0.0811
0.033
0.4008
0.0761
0.506
0.2284
0.1169
0.0275
4 0.265
0.0923
0.0858
0.0353
0.0133
0.074
0.0254
0.0427
0.2667
0.0807
5 0.138
0.7437
0.0289
0.1801
0.2989
0.2411
0.2744
0.6473
0.0096
0.625
1 0.3348 0.5666 0.1476 0.8179 0.0642 0.7671 0.1409 0.1401 0.0839 0.2898
2 0.0613 0.2366 0.0104 0.0678 0.0194 0.1281 0.0551 0.1484 0.1244 0.0276
80
0.0188
0.0018
0.4753
0.5336
0.7007
0.4906
4 0.0883 0.1515 0.2035 0.0274 0.2084 0.0205 0.0135 0.0571 0.0486 0.1709
5 0.3828 0.0145 0.458
0.0069
0.6892
0.0826
0.3152
0.1209
0.0424
0.0211
0.0043
0.0239
0.0123
0.7735
0.2311
0.6981
2 0.2789 0.4667 0.0077 0.0585 0.1216 0.9661 0.0382 0.0074 0.2254 0.1076
90
0.0716
0.0558
0.0904
0.1315
0.0814
0.4502
0.0088
0.0029
0.054
U randomly generated initial value of the position of each row uij [0, 1], and satisfies
the equation
.
Table 3. Final Clustering Matrices
n-points c 1+n
1 0
0
10
2+n
3+n
4+n
5+n
6+n
7+n
8+n
9+n 10+n
0.0001
0.9995
0.0262
2 0.0005 0
0.9818
0.0005
0.0001
0.0001
3 0.0017 1
0.9989
0.9999
4 0.9978 0
0.018
0.0008
0.0001
5 0
0.0001
0.9737
0.9999
0.0003
2 0
0.028
0.0281
0.0006
0.9997
3 0
0.3752
0.3052
0.006
4 0
0.5948
0.6649
0.9933
0.0001
0.0003
2 0.0006 0.0067 0
0.0003
0.0073
0.0001
0.0349
0.525
0.0001
4 0
30
40
50
60
70
80
0.0008
0.4746
1 0
0.0011
0.0003
0.0005
0.0001
0.0011
2 0
0.0003
0.9999
0.0031
0.0071
0.0005
3 0
0.0878
0.0063
0.9999
0.9865
0.7293
4 1
0.0002
0.0001
0.0078
0.9929
0.0006
5 0
0.9106
0.9933
0.0021
0.9999
0.2684
1 0
0.0057
0.0134
0.0141
0.0001
0.9999
0.9717
2 0
0.0005
0.9864
0.0017
0.0001
0.0182
0.0279
3 1
0.9604
0.0088
0.9926
0.0001
4 0
0.039
0.0002
0.0003
0.0002
0.9817
0.0001
5 0
0.0001
0.9942
0.9751
0.007
0.0003
1 0
0.0001
0.0004
0.0003
2 0
0.0011
0.0001
0.0043
0.0001
0.0002
0.0004
3 1
0.9116
0.9663
0.9982
0.969
0.9823
4 0
0.087
0.9999
0.0279
0.0016
0.0002
0.0172
5 0
0.0002
0.001
0.0001
0.0302
0.0001
1 0
0.0033
0.9993
0.0205
0.0002
0.7212
2 0
0.9349
0.0007
0.0004
0.0193
3 0
0.9997
0.0027
0.9953
0.0031
4 0
0.0586
0.0005
0.0008
5 1
0.0002
0.0005
0.9794
0.0035
0.2555
1 0
0.0014
0.0002
0.3831
0.9996
2 0
0.0001
0.001
0.0001
0.0004
0.6163
0.0003
3 0.9998 0.001
0.0001
0.9705
0.0002
4 0
0.9999
0.999
0.0001
0.9994
0.0003
5 0.0001 0.9975 0
0.0291
0.0003
0.0001
1 1
0.0041
0.0001
0.9996
0.3394
2 0
0.0008
0.0001
0.0065
0.0003
0.6602
3 0
0.0183
0.99
0.0016
4 0
0.0002
0.0002
0.9935
0.9981
0.0002
5 0
0.9766
0.0096
0.0004
0.0002
0.9999
0.0062
0.9878
0.7799
0.0001
0.0001
0.0003
0.0001
4 0
1 0.0019 0.0002 0
90
0.2361
5 0.9976 0
0.0008
0.0001
0.0009
0.0002
0.0001
0.0002
0.9937
0.012
0.2197
%%%Clustering Program
U0=zeros(c,P);
[ra,ca]=size(Range_a);
[rb,cb]=size(Range_b);
cost_f = [];
iter=1;
%%% Clustering
while 1
hold off
%Drawing data points clustering
for i=1:P
[val,ind]=sort(U0(:,i));
if ind(c)==1
plot(ab(1,i),ab(2,i),'ro')
elseif ind(c)==2
plot(ab(1,i),ab(2,i),'g^')
elseif ind(c)==3
plot(ab(1,i),ab(2,i),'b+')
elseif ind(c)==4
plot(ab(1,i),ab(2,i),'k*')
elseif ind(c)==5
plot(ab(1,i),ab(2,i),'msquare')
end
hold on;
end
Uold = U0;
%Center of gravity
for i = 1:c
v(1,i) = sum(ab(1,:).*(U0(i,:).^m) ) ./ sum(U0(i,:).^m);
v(2,i) = sum(ab(2,:).*(U0(i,:).^m) ) ./ sum(U0(i,:).^m);
end
%Draw the change of center of gravity
plot(v(1,1),v(2,1),'p','Markersize',10,'MarkerFaceColor','r')
plot(v(1,2),v(2,2),'p','Markersize',10,'MarkerFaceColor','g')
plot(v(1,3),v(2,3),'p','Markersize',10,'MarkerFaceColor','b')
plot(v(1,4),v(2,4),'p','Markersize',10,'MarkerFaceColor','k')
plot(v(1,5),v(2,5),'p','Markersize',10,'MarkerFaceColor','m')
pause(0.1+(iter==1)*0.9);
cost(j) = sum(ncost);
end
cost_f(iter) = sum(cost);% Each iteration of the cost function
if E==1
%Draw the focus point
plot(v(1,1),v(2,1),'p','Markersize',15,'MarkerFaceColor','r')
plot(v(1,2),v(2,2),'p','Markersize',15,'MarkerFaceColor','g')
plot(v(1,3),v(2,3),'p','Markersize',15,'MarkerFaceColor','b')
plot(v(1,4),v(2,4),'p','Markersize',15,'MarkerFaceColor','k')
plot(v(1,5),v(2,5),'p','Markersize',15,'MarkerFaceColor','m')
pause(1)
10
(5) Use different colors to show the points of different clusters in the X-Y
space
Using different color and symbols , , , , + represents a different grouping of data
points on behalf of small convergence trajectory focus of value changes, large
the focus of the last representatives. Weight m = 1.25 and error rate = 0.01 randomly
generated clustering results 100 points.
11
12
14
Conclusion:
-
In the "fuzzy C-mean clustering method", the selection of the weights need the
reasonable value, generally choose weight = 1.25 and it cant be less than or equal
to 1, otherwise it will affect the center of gravity.
15