I try to run this code but i have an error : ValueError: Number of labels is 1. Valid values are 2 to n_samples - 1 (inclusive). Furthermore, it is said that : Affinity propagation did not converge, this model will not have any cluster centers. What is the solution for these 2 problems
preferences = range(-15000,-5000,50) # arbitraty chosen range
af_sil_score = [] # silouette scores
for p in preferences:
AF = AffinityPropagation(preference=p, max_iter=200).fit(X)
no_of_clusters.append((len(np.unique(AF.labels_))))
af_sil_score.append(silhouette_score(X, AF.labels_))
af_results = pd.DataFrame([preferences, no_of_clusters, af_sil_score], index=['preference','clusters', 'sil_score']).T
af_results.sort_values(by='sil_score', ascending=False).head() # display only 5 best scores```