skearn.cluster.AffiinityPropagation


AP algorithm:

http://blog.csdn.net/lixi__liu/article/details/48470173

http://wenku.baidu.com/link?url=wthd1z0wj8qgunjxd3S-jgIpefnx-LgS5vCsvsl33RASsoUHjstIIfMwSWtb223EUb6HG8hLiEpwGAw8o4o0JkNvV-3CFS7Cj335dq40xx_

Two important  parameters:

Damping:bigger damping result in more computing time and reduce oscillation.

Preference:bigger preference result in more clusters.

          Preference is the main diagonal elements of similarity matrix.

Rather than requiring that the number of clusters be prespecified, affinity propagation takes as inputa real number s(k,k)

for each data point kso that data points with larger valuesof s(k,k) are more likely to be chosen as exemplars.

These values are referred to as “preferences.”

                                                       --<Clustering by Passing Messages Between Data Points Brendan> J. Frey* and Delbert Dueck,<Science07>


from sklearn.cluster import  AffinityPropagation

parameters:

damping : float, optional, default: 0.5

Damping factor between 0.5 and 1.

convergence_iter : int, optional, default: 15

Number of iterations with no change in the number of estimated clusters that stops the convergence.

max_iter : int, optional, default: 200

Maximum number of iterations.

copy : boolean, optional, default: True

Make a copy of input data.

preference : array-like, shape (n_samples,) 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.

affinity : string, optional, default=``euclidean``

Which affinity to use. At the moment precomputed and euclidean are supported. euclidean uses the negative squared euclidean distance between points.

If affinity=='precomputed',must input a similarity matrix,else AffinityPropagation.fit method can help you compute similarity matrix by negative euclidean distance and you can input a matrix which consists of examples and features.

verbose : boolean, optional, default: False

Whether to be verbose.


attributes:

cluster_centers_indices_ : array, shape (n_clusters,)

Indices of cluster centers

cluster_centers_ : array, shape (n_clusters, n_features)

Cluster centers (if affinity != precomputed).

Since input is similarity matrix,we don't have cluster_centers_ which is a example consist of features's values.

labels_ : array, shape (n_samples,)

Labels of each point

affinity_matrix_ : array, shape (n_samples, n_samples)

Stores the affinity matrix used in fit.

Which is similarity matrix.Return origin similarity matrix rather than the similarity matrix which main diagonal elements is replaced by preferences.

n_iter_ : int

Number of iterations taken to converge.

method:

fit(X[, y]) Create affinity matrix from negative euclidean distances, then apply affinity propagation clustering.
fit_predict(X[, y]) Performs clustering on X and returns cluster labels.
get_params([deep]) Get parameters for this estimator.
predict(X) Predict the closest cluster each sample in X belongs to.
set_params(\*\*params) Set the parameters of this estimator.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值