sklearn.cluster.SpectralClustering
比較的まばらな特徴がかなりあるデータセットにスペクトル クラスタリング ( ) を適用しています。Python でスペクトル クラスタリングを実行すると、次の警告が表示されます。
UserWarning: Graph is not fully connected, spectral embedding may not work as expected. warnings.warn("Graph is not fully connected, spectral embedding"
これに続いて、次のようなエラーが発生することがよくあります。
`
File "****.py", line 120, in perform_clustering_spectral_clustering
predicted_clusters = cluster.SpectralClustering(n_clusters=n).fit_predict(features)
File "****\sklearn\base.py", line 349, in fit_predict
self.fit(X)
File "****\sklearn\cluster\spectral.py", line 450, in fit
assign_labels=self.assign_labels)
File "****\sklearn\cluster\spectral.py", line 256, in spectral_clustering
eigen_tol=eigen_tol, drop_first=False)
File "****\sklearn\manifold\spectral_embedding_.py", line 297, in spectral_embedding
largest=False, maxiter=2000)
File "****\scipy\sparse\linalg\eigen\lobpcg\lobpcg.py", line 462, in lobpcg
activeBlockVectorBP, retInvR=True)
File "****\scipy\sparse\linalg\eigen\lobpcg\lobpcg.py", line 112, in _b_orthonormalize
gramVBV = cholesky(gramVBV)
File "****\scipy\linalg\decomp_cholesky.py", line 81, in cholesky
check_finite=check_finite)
File "****\scipy\linalg\decomp_cholesky.py", line 30, in _cholesky
raise LinAlgError("%d-th leading minor not positive definite" % info)
numpy.linalg.linalg.LinAlgError: 9-th leading minor not positive definite
numpy.linalg.linalg.LinAlgError: 9-th leading minor not positive definite
numpy.linalg.linalg.LinAlgError: the leading minor of order 12 of 'b' is not positive definite. The factorization of 'b' could not be completed and no eigenvalues or eigenvectors were computed.`
ただし、この警告/エラーは、同じ設定を使用している場合に常に発生するとは限りません (つまり、動作があまり一貫していないため、テストが困難になります)。n_clusters のさまざまな値で発生しますが、値 n=2 および n > 7 でより頻繁に発生します (これは少なくとも私の簡単な経験です。前述したように、その動作はあまり一貫していません)。
この警告と関連するエラーにどのように対処すればよいですか? 機能の量に依存しますか?さらに追加するとどうなりますか?