我想将 T-sne 功能用于 DBSCAN 聚类算法,但 sklearn 实现未针对 n_components>4 运行。
from sklearn.manifold import TSNE
X = np.array([[0, 0, 0,2, 0, 0,2], [0, 1, 1,53, 0, 0,2], [1, 0, 1,12, 0, 0,2], [1, 1, 1,75, 0, 0,2]])
X_embedded = TSNE(n_components=5).fit_transform(X)
错误:
ValueError Traceback (most recent call last)
<ipython-input-22-79c671f39a06> in <module>
----> 1 tsne_data = model.fit(clustering_ready_data_encoded)
~/anaconda3/lib/python3.8/site-packages/sklearn/manifold/_t_sne.py in fit(self, X, y)
902 y : Ignored
903 """
--> 904 self.fit_transform(X)
905 return self
~/anaconda3/lib/python3.8/site-packages/sklearn/manifold/_t_sne.py in fit_transform(self, X, y)
884 Embedding of the training data in low-dimensional space.
885 """
--> 886 embedding = self._fit(X)
887 self.embedding_ = embedding
888 return self.embedding_
~/anaconda3/lib/python3.8/site-packages/sklearn/manifold/_t_sne.py in _fit(self, X, skip_num_points)
685
686 if self.method == 'barnes_hut' and self.n_components > 3:
--> 687 raise ValueError("'n_components' should be inferior to 4 for the "
688 "barnes_hut algorithm as it relies on "
689 "quad-tree or oct-tree.")
ValueError: 'n_components' should be inferior to 4 for the barnes_hut algorithm as it relies on quad-tree or oct-tree.
我知道 T-sne 不适合聚类算法中的功能,但我仍想尝试。