使用字向量进行关联传播,实现速度更快

2024-09-28 01:25:56 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个单词向量列表(名为tuple\u vectors-length~60k),每个单词向量如下所示:

  [-2.84658718e+00 -7.74899840e-01 -2.24296474e+00 -8.69364500e-01
  3.90927410e+00 -2.65316987e+00 -9.71897244e-01 -2.40408254e+00
  1.16272974e+00 -2.61649752e+00 -2.87350488e+00 -1.06603658e+00
  2.93374014e+00  1.07194626e+00 -1.86619771e+00  1.88549474e-01
 -1.31901133e+00  3.83382154e+00 -3.46174908e+00 -2.94792175e-01
 -2.77922183e-01 -7.64171720e-01 -2.99903727e+00 -2.41594386e+00 ...

我正在尝试使用以下内容执行关联传播(AP)(这是AP文档https://scikit-learn.org/stable/auto_examples/cluster/plot_affinity_propagation.html的顶部部分):

print(__doc__)

from sklearn.cluster import AffinityPropagation
from sklearn import metrics

# Compute Affinity Propagation
af = AffinityPropagation(preference=-50).fit(tuple_vectors)
cluster_centers_indices = af.cluster_centers_indices_
labels = af.labels_

n_clusters_ = len(cluster_centers_indices)

这个过程需要很长时间。我的问题是是否有一个更快的实现,或者是否有可能在这个维度的向量上执行AP。你知道吗


Tags: fromimport列表labelssklearn单词向量ap

热门问题