'How to converge my Affinity Propagation clustering

I am trying to cluster using affinity propagation function from sklearn, and I load the wine dataset from sklearn datasets for practice,but I found the result seems to be divergent more. the following is my coding and output. Is there anyone can help to converge it?

## Affinity Propagate clustering
# preference=-200
af1=AffinityPropagation(damping=0.6, ##damping coefficient
                       preference=-200)## demo sample numbers
af1.fit(tsne_wine_x)
## output the clustering result
af1.labels_
print("affinitypropagation1:\n each cluster contains sample numbers:",np.unique(af1.labels_,return_counts=True))
print("the center of each cluster:\n",af1.cluster_centers_)
print("cluster effect measurement: %.4f"%v_measure_score(wine_y,af1.labels_))

# prefernence=-300
af2=AffinityPropagation(damping=0.6, ##damping coefficient
                       preference=-300,)## demo sample numbers
af2.fit(tsne_wine_x)
## output the clustering result
af2.labels_
print("affinitypropagation1:\n each cluster contains sample numbers:",np.unique(af1.labels_,return_counts=True))
print("the center of each cluster:\n",af2.cluster_centers_)
print("cluster effect measurement: %.4f"%v_measure_score(wine_y,af2.labels_))

output as follows:

affinitypropagation1:
 each cluster contains sample numbers: (array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
       17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
       34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
       51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
       68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
       85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98],
      dtype=int64), array([1, 1, 3, 1, 1, 4, 1, 1, 2, 2, 2, 3, 2, 3, 2, 1, 3, 1, 1, 3, 3, 3,
       1, 1, 3, 2, 1, 1, 2, 2, 2, 1, 3, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1,
       1, 1, 3, 4, 1, 3, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 4,
       1, 1, 1, 1, 2, 3, 4, 1, 1, 1, 2, 3, 3, 2, 2, 1, 1, 3, 3, 1, 2, 1,
       2, 2, 3, 4, 3, 2, 2, 1, 2, 3, 1], dtype=int64))
the center of each cluster:
 [[-48.37732     49.8868      39.811954  ]
 [-84.306404    50.147316     2.9238791 ]
 [-46.66801     23.65031     50.640266  ]
 [-60.248363    11.670533    37.593285  ]
 [-47.796566    43.252514   -12.578477  ]
 [-50.23032     27.095114     6.4264565 ]
 [-76.76005     72.59616      0.5859382 ]
 [-80.56087     66.409424    11.2069435 ]
 [-62.626854    32.25013     35.819237  ]
 [-89.04437     40.46149     18.92361   ]
 [-28.621351    57.653408    28.343428  ]
 [-35.21245     70.90178     17.74187   ]
 [-35.0851      37.742958    11.84398   ]
 [-33.479362    28.0133      31.076523  ]
 [-61.80723     18.310999     9.577278  ]
 [-63.085262    47.821674    39.784695  ]
 [-67.42685     45.943687    21.418894  ]
 [-47.040802     8.935648     3.1647332 ]
 [-68.00408     22.875055    47.69129   ]
 [-49.070473    18.820766    26.645557  ]
 [-25.46838     25.739283    -4.831076  ]
 [-32.210728     3.1240163   50.45797   ]
 [-46.79468      1.9864745   45.20599   ]
 [-56.063374    69.330536    -0.93588656]
 [-44.301167    57.627472    -2.4235806 ]
 [-53.07226     46.984806    26.32008   ]
 [-41.711025    61.147305   -17.281782  ]
 [-76.76144     39.251816    -2.1477308 ]
 [-69.82143     21.194693    32.508224  ]
 [-38.13094     55.14129     15.620863  ]
 [-69.9092      50.146976     5.6761813 ]
 [  7.61815     20.22642    -27.340418  ]
 [-12.432432   -23.8001     -29.112923  ]
 [ 19.059591    22.08616    -12.335601  ]
 [ -0.5897775   35.889137    14.374662  ]
 [-23.867905   -23.982252   -14.178696  ]
 [-32.684708     3.7091634   14.405653  ]
 [ -3.8368435   38.634743    -2.1947575 ]
 [ 11.202627    19.6814       3.425875  ]
 [ 17.983934    -3.0506208  -25.795122  ]
 [-26.316021    35.951195    40.836388  ]
 [ 20.060356    19.177086    19.397114  ]
 [-55.014297    40.634064    57.835793  ]
 [ -5.2303553   37.534954    30.04933   ]
 [  0.6572533    6.5139194  -19.428473  ]
 [  3.7029684   -7.5797668  -22.29294   ]
 [ -8.820529    68.6681      -7.232877  ]
 [-28.667152   -22.649517     8.827736  ]
 [ 16.47699    -38.838287     1.3740513 ]
 [-12.157445     6.2976418    7.6571326 ]
 [-10.477531   -22.861034    12.085887  ]
 [ -0.1971891  -30.422308    -7.410164  ]
 [ -8.285736    12.634719    24.412964  ]
 [ -0.2980544   25.290798    24.547184  ]
 [ -5.9154077   22.673038    -0.90580344]
 [-20.64679      4.5603685   30.143646  ]
 [ -7.3200207   19.651293   -16.010586  ]
 [ 10.039293     8.335278    -7.3766937 ]
 [ -0.736834   -39.12756     10.237442  ]
 [ 21.964504    -1.0646577   18.783588  ]
 [ -2.5084066   18.652403    45.84101   ]
 [-22.692217   -38.27734    -11.620276  ]
 [-19.597004   -10.985454    11.255304  ]
 [-11.036084   -13.647176    24.503866  ]
 [-26.762087    -5.6738124   -6.332348  ]
 [ 10.927241     3.040745     9.4539585 ]
 [ -3.3703058   -3.1905448   14.812418  ]
 [ 17.485968   -21.609922   -13.758996  ]
 [ 15.278203   -11.606305     8.411929  ]
 [-37.36634     27.456478    67.03539   ]
 [-13.546518   -18.410439    42.766376  ]
 [ -4.789019     2.317888    56.976112  ]
 [  8.111803    -2.2190175   26.131933  ]
 [ -8.125454   -31.939026    29.90172   ]
 [  3.1642723  -15.800813    23.292624  ]
 [ 16.666946   -26.291895    15.783055  ]
 [ 24.662346    -3.9587426  -42.155624  ]
 [ 34.09528    -10.4245205  -34.60794   ]
 [ 14.352393   -36.74348    -27.99642   ]
 [ 28.13137    -54.048122     9.151959  ]
 [ 11.693304   -51.79257    -13.341043  ]
 [ 44.30936     -6.20026    -20.332747  ]
 [ 42.82923    -26.731495     3.934676  ]
 [ 47.411762   -42.57104    -23.415197  ]
 [ 58.058033   -11.024979   -41.63126   ]
 [ 68.270676   -36.73454     -7.052488  ]
 [ 55.19679    -52.89744     -3.718941  ]
 [ 32.338867   -68.84859    -12.2562895 ]
 [ 79.16199    -43.01711    -33.022163  ]
 [ 45.75389    -56.95327    -20.3191    ]
 [ 23.29159    -54.37454     -8.336856  ]
 [ 34.642002   -19.135109   -23.69629   ]
 [ 38.789536   -35.04331     -8.224047  ]
 [ 65.04322    -27.289017   -25.34089   ]
 [ 39.674923   -49.487076   -34.37203   ]
 [ 70.68941    -18.826406   -37.9513    ]
 [ 55.52562    -44.642315   -34.88949   ]
 [ 56.64951    -15.53858    -14.366445  ]
 [ 63.755486   -48.67671    -21.341312  ]]
cluster effect measurement: 0.3884
affinitypropagation1:
 each cluster contains sample numbers: (array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
       17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
       34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
       51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
       68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
       85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98],
      dtype=int64), array([1, 1, 3, 1, 1, 4, 1, 1, 2, 2, 2, 3, 2, 3, 2, 1, 3, 1, 1, 3, 3, 3,
       1, 1, 3, 2, 1, 1, 2, 2, 2, 1, 3, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1,
       1, 1, 3, 4, 1, 3, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 4,
       1, 1, 1, 1, 2, 3, 4, 1, 1, 1, 2, 3, 3, 2, 2, 1, 1, 3, 3, 1, 2, 1,
       2, 2, 3, 4, 3, 2, 2, 1, 2, 3, 1], dtype=int64))
the center of each cluster:
 [[-48.37732    49.8868     39.811954 ]
 [-77.60652    39.0176     12.058848 ]
 [-50.23032    27.095114    6.4264565]
 [-80.56087    66.409424   11.2069435]
 [-62.626854   32.25013    35.819237 ]
 [-33.479362   28.0133     31.076523 ]
 [-49.672836   27.080494   61.710384 ]
 [-41.977703   41.215004    1.2116675]
 [-67.42685    45.943687   21.418894 ]
 [-42.672035   15.583638   16.082884 ]
 [-25.46838    25.739283   -4.831076 ]
 [-29.469215   68.762985   33.649837 ]
 [-32.210728    3.1240163  50.45797  ]
 [-44.301167   57.627472   -2.4235806]
 [-69.82143    21.194693   32.508224 ]
 [-46.96176    64.296326   12.42852  ]
 [-69.9092     50.146976    5.6761813]
 [-12.432432  -23.8001    -29.112923 ]
 [ 11.202627   19.6814      3.425875 ]
 [ 20.060356   19.177086   19.397114 ]
 [  5.761611   24.733463  -11.186087 ]
 [  3.7029684  -7.5797668 -22.29294  ]
 [ -8.820529   68.6681     -7.232877 ]
 [-18.106163   -6.8944445  40.884716 ]
 [-28.667152  -22.649517    8.827736 ]
 [ 16.47699   -38.838287    1.3740513]
 [-12.157445    6.2976418   7.6571326]
 [-10.79391   -30.020985    1.5433844]
 [ -0.2980544  25.290798   24.547184 ]
 [ -8.048084   43.399197   13.030614 ]
 [ -2.5084066  18.652403   45.84101  ]
 [-22.692217  -38.27734   -11.620276 ]
 [-26.762087   -5.6738124  -6.332348 ]
 [ 10.927241    3.040745    9.4539585]
 [ 17.485968  -21.609922  -13.758996 ]
 [ -4.789019    2.317888   56.976112 ]
 [  8.111803   -2.2190175  26.131933 ]
 [ -8.125454  -31.939026   29.90172  ]
 [ 16.666946  -26.291895   15.783055 ]
 [ 24.662346   -3.9587426 -42.155624 ]
 [ 14.352393  -36.74348   -27.99642  ]
 [ 28.13137   -54.048122    9.151959 ]
 [ 42.158104  -49.218536  -11.018628 ]
 [ 58.058033  -11.024979  -41.63126  ]
 [ 55.272266  -39.948742  -12.402799 ]
 [ 32.338867  -68.84859   -12.2562895]
 [ 79.16199   -43.01711   -33.022163 ]
 [ 23.29159   -54.37454    -8.336856 ]
 [ 34.642002  -19.135109  -23.69629  ]
 [ 38.789536  -35.04331    -8.224047 ]
 [ 39.674923  -49.487076  -34.37203  ]
 [ 59.349792  -29.687374  -36.61007  ]
 [ 56.64951   -15.53858   -14.366445 ]]
cluster effect measurement: 0.4150

I wonder if the problem is the damping coefficient set. Anyone can help?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source