我尝试过这个:
In [1]: import sklearn
In [2]: from sklearn.manifold import TSNE
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
/home/intern/<ipython-input-2-9afc8da4e1e3> in <module>()
----> 1 from sklearn.manifold import TSNE
ImportError: cannot import name TSNE
实际上 TSNE 并不存在于我的 sklearn.manifold 中,但在 sklearn 文档中它必须存在。
最佳答案
TSNE 目前在 sklearn 中不可用。但它在sklearn的开发版本中可用。以下是如何构建库并在 ubuntu 上安装
#Install dependencies for building sklearn
sudo apt-get install build-essential python-dev python-setuptools \
python-numpy python-scipy \
libatlas-dev libatlas3gf-base
sudo pip install cython
git clone "https://github.com/scikit-learn/scikit-learn.git"
cd scikit-learn
make
sudo python setup.py install
然后在 python 控制台中尝试以下操作
from sklearn.manifold import TSNE
关于python - 尝试使用 sklearn 中的 TSNE 来可视化我的高维数据,但出现导入错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31077145/