8.1.1. sklearn.cluster.AffinityPropagation¶
- class sklearn.cluster.AffinityPropagation(damping=0.5, max_iter=200, convit=30, copy=True)¶
Perform Affinity Propagation Clustering of data
Parameters : damping : float, optional
Damping factor
max_iter : int, optional
Maximum number of iterations
convit : int, optional
Number of iterations with no change in the number of estimated clusters that stops the convergence.
copy: boolean, optional :
Make a copy of input data. True by default.
Notes
See examples/plot_affinity_propagation.py for an example.
The algorithmic complexity of affinity propagation is quadratic in the number of points.
References
Brendan J. Frey and Delbert Dueck, “Clustering by Passing Messages Between Data Points”, Science Feb. 2007
Attributes
cluster_centers_indices_ array, [n_clusters] Indices of cluster centers labels_ array, [n_samples] Labels of each point Methods
fit(S[, p]) Compute affinity propagation clustering. get_params([deep]) Get parameters for the estimator set_params(**params) Set the parameters of the estimator. - __init__(damping=0.5, max_iter=200, convit=30, copy=True)¶
- fit(S, p=None)¶
Compute affinity propagation clustering.
Parameters : S: array [n_points, n_points] :
Matrix of similarities between points
p: array [n_points,] or float, optional :
Preferences for each point - points with larger values of preferences are more likely to be chosen as exemplars. The number of exemplars, ie of clusters, is influenced by the input preferences value. If the preferences are not passed as arguments, they will be set to the median of the input similarities.
damping : float, optional
Damping factor
copy: boolean, optional :
If copy is False, the affinity matrix is modified inplace by the algorithm, for memory efficiency
- get_params(deep=True)¶
Get parameters for the estimator
Parameters : deep: boolean, optional :
If True, will return the parameters for this estimator and contained subobjects that are estimators.
- set_params(**params)¶
Set the parameters of the estimator.
The method works on simple estimators as well as on nested objects (such as pipelines). The former have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.
Returns : self :