Python SKlearn 导入 MLPClassifier 失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34016238/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SKlearn import MLPClassifier fails
提问by maniac
I am trying to use the multilayer perceptronfrom scikit-learn in python. My problem is, that the import is not working. All other modules from scikit-learn are working fine.
我正在尝试在 python 中使用来自 scikit-learn的多层感知器。我的问题是,导入不起作用。scikit-learn 的所有其他模块都运行良好。
from sklearn.neural_network import MLPClassifier
Import Error: cannot import name MLPClassifier
导入错误:无法导入名称 MLPClassifier
I'm using the Python Environment Python64-bit 3.4 in Visual Studio 2015.
I installed sklearn over the console with: conda install scikit-learn
I also installed numpy and pandas. After I had the error above I also installed scikit-neuralnetworkwith: pip install scikit-neuralnetwork
The installed scikit-learn version is 0.17.
我在 Visual Studio 2015 中使用 Python 环境 Python64 位 3.4。我通过控制台安装了 sklearn:conda install scikit-learn
我还安装了 numpy 和 pandas。出现上述错误后,我还安装了scikit-neuralnetwork:pip install scikit-neuralnetwork
安装的 scikit-learn 版本为 0.17。
What have I done wrong? Am I missing an installation?
我做错了什么?我缺少安装吗?
----- EDIT ----
- - - 编辑 - -
In addition to the answer of tttthomasssss, I found the solution on how to install the sknn library for neuronal networks. I followed this tutorial. Do the following steps:
除了tttthomasssss的答案,我找到了关于如何为神经元网络安装sknn库的解决方案。我跟着这个教程。执行以下步骤:
pip install scikit-neuralnetwork
- download and install the GCC compiler
- install mingw with
conda install mingw libpython
pip install scikit-neuralnetwork
- 下载并安装GCC 编译器
- 安装 mingw
conda install mingw libpython
You can use the sknnlibrary after.
您可以在之后使用sknn库。
采纳答案by tttthomasssss
MLPClassifier
is not yet available in scikit-learn
v0.17 (as of 1 Dec 2015). If you really want to use it you could clone 0.18dev
(however, I don't know how stable this branch currently is).
MLPClassifier
在scikit-learn
v0.17 中尚不可用(截至 2015 年 12 月 1 日)。如果你真的想使用它,你可以克隆0.18dev
(但是,我不知道这个分支目前有多稳定)。
回答by 0_0
I arrived here with the v0.17 problem too. I found a solution using pip here, namely
我也带着 v0.17 问题来到这里。我在这里找到了一个使用 pip 的解决方案,即
pip install git+https://github.com/scikit-learn/scikit-learn.git
I had to execute pip install cython
first though.
不过我必须先执行pip install cython
。
However, that installs 0.19.dev0
(currently), but pip list
indicates that the latest is 0.18rc2
. Rather
但是,安装0.19.dev0
(当前),但pip list
表明最新的是0.18rc2
. 相当
pip install scikit-learn==0.18.rc2
resolved the issue more satisfactorily.
更满意地解决了这个问题。
回答by MAFiA303
from shell/ terminal
从外壳/终端
conda update scikit-learn
回答by Shabaz Patel
apt-get update; \
apt-get install -y python python-pip \
python-numpy \
python-scipy \
build-essential \
python-dev \
python-setuptools \
libatlas-dev \
libatlas3gf-base
update-alternatives --set libblas.so.3 /usr/lib/atlas-base/atlas/libblas.so.3; update-alternatives --set liblapack.so.3 /usr/lib/atlas-base/atlas/liblapack.so.3
pip install -U scikit-learn
I have imported MLPClassifier from sklearn.neural_network and it does seem to work.
我已经从 sklearn.neural_network 导入了 MLPClassifier,它似乎确实有效。
You could also handle this issues by using docker images. This allows any developer to recreate the environment in any server within a single minute. You can pull the image from here
您也可以使用 docker 镜像来处理这个问题。这允许任何开发人员在一分钟内在任何服务器中重新创建环境。你可以从这里拉图像
This can also be performed very easily using the datmo-cli tool. We faced these problems ourselves and decided to build it.
使用 datmo-cli 工具也可以非常轻松地执行此操作。我们自己面对这些问题并决定建造它。
You could also solve this with one click using Datmo Disclaimer: I work at Datmo
您也可以使用 Datmo 一键解决此问题免责声明:我在Datmo工作