Ich verwende Spectral Clustering Library in Python und Ähnlichkeitsmatrix ist das Hauptargument. Meine Matrix wie folgt aussieht:Sklearn Spectral Clustering Fehler in fit_predict: k muss zwischen 1 und der Reihenfolge der quadratischen Eingabematrix sein
[[ 1. 0.85018854 0.85091491 0.85717652]
[ 0.85018854 1. 0.99720197 0.99732831]
[ 0.85091491 0.99720197 1. 0.9972462 ]
[ 0.85717652 0.99732831 0.9972462 1. ]]
Und meinen Code ähnlich wie die Dokumentation Proben:
cl = SpectralClustering(n_clusters=4,affinity='precomputed')
y = cl.fit_predict(matrix)
Aber der folgenden Fehler tritt auf:
Traceback (most recent call last):
File "/home/mahmood/PycharmProjects/sentence2vec/graphClustering.py", line 22, in <module>
y = cl.fit_predict(matrix)
File "/usr/local/lib/python2.7/dist-packages/scikit_learn-0.17.1-py2.7-linux-x86_64.egg/sklearn/base.py", line 371, in fit_predict
self.fit(X)
File "/usr/local/lib/python2.7/dist-packages/scikit_learn-0.17.1-py2.7-linux-x86_64.egg/sklearn/cluster/spectral.py", line 454, in fit
assign_labels=self.assign_labels)
File "/usr/local/lib/python2.7/dist-packages/scikit_learn-0.17.1-py2.7-linux-x86_64.egg/sklearn/cluster/spectral.py", line 258, in spectral_clustering
eigen_tol=eigen_tol, drop_first=False)
File "/usr/local/lib/python2.7/dist-packages/scikit_learn-0.17.1-py2.7-linux-x86_64.egg/sklearn/manifold/spectral_embedding_.py", line 254, in spectral_embedding
tol=eigen_tol)
File "/usr/lib/python2.7/dist-packages/scipy/sparse/linalg/eigen/arpack/arpack.py", line 1507, in eigsh
raise ValueError("k must be between 1 and the order of the "
ValueError: k must be between 1 and the order of the square input matrix.
Ich habe keine Ahnung, und ich muß wissen, Was ist das Problem und vielleicht ist es eine Lösung.
Danke für die richtige Antwort –