python - importing subpackages of sci-kit learn 'Unknown location'
问题描述
I try to do some PCA and TSNE analyses. I want to use sklearn to import the PCA and TSNE package. Internet says that I should use these imports
from sklearn.decomposition import PCA
from sklearn.manifold import TSNE
https://scikit-learn.org/stable/modules/generated/sklearn.decomposition.PCA.html https://scikit-learn.org/stable/modules/generated/sklearn.manifold.TSNE.html
However, I get this message when I try to import those.
ImportError: cannot import name 'PCA' from 'sklearn.decomposition' (unknown location)
I did install sklearn and am able to import sklearn.decomposition and sklearn.manifold. However, If I I try to do this:
import sklearn.decomposition as decom
decom.PCA
I get the same ImportError. I tried reinstalling sklearn and updating it, but that doesn't solve the problem. Does one of you have a clue of what I'm doing wrong? I'm using Python 3.7.8 and use jupyter lab with MiniConda.
The documentation of sklearn is version 23.2 and that is the same version as my scikit-learn is.
EDIT: I created a totally new virtual environment and now my dir(decom) is totally different. And those packages for PCA and TSNE are working. Could somebody enlighten me why those are not working in the my current environment? Does it have to do with incompatible packages? I did not get any warning for it. It is sort of solved, yet I'm curious what the reason is and how I can fix it in the future.
解决方案
推荐阅读
- java - 为什么在 Spring Boot 中没有替换验证消息?
- smtp - 配置 odoo 出入邮件
- javascript - 如何减少 docusaurus 构建 (v2) 的内存使用量?
- python - Python wrapper arround fasttext train 与参数调整
- git - 与不同的分支解绑
- javascript - 我想根据 Laravel Blade 中的用户 ID 显示模态弹出窗口并将数据传递给模态
- entity-framework - 如何使用 EF 3.1 为实体框架 GroupBy 中的每个组选择前 N 行
- r - 如何使用应用于多行的条件来选择个人?
- r - 直接在 ggplot aes 中闪亮的输入变量(RMarkdown flexdashboard)
- assembly - 为什么在使用双打时这个分支问题在 MIPS 中不起作用?