酷徒LOGO
0 0 评论

正文
文章标签:了解scikit  Anaconda  learn  

步骤1:设置和安装scikit-learn

使用conda,我们实际上可以创建环境并使用一个命令安装scikit :

root@ubuntu:~# conda create --name conda-scikit scikit-learn

你应该看到类似于此的输出,并带有提示,此提示要求许可conda外出并获取scikit-learn可能需要的依赖项,在终端中输入" y",然后按Enter键继续安装:


The following NEW packages will be INSTALLED:

  _libgcc_mutex      pkgs/main/linux-64::_libgcc_mutex-0.1-main
  blas               pkgs/main/linux-64::blas-1.0-mkl
  ca-certificates    pkgs/main/linux-64::ca-certificates-2019.10.16-0
  certifi            pkgs/main/linux-64::certifi-2019.9.11-py37_0
  intel-openmp       pkgs/main/linux-64::intel-openmp-2019.4-243
  joblib             pkgs/main/linux-64::joblib-0.13.2-py37_0
  libedit            pkgs/main/linux-64::libedit-3.1.20181209-hc058e9b_0
  libffi             pkgs/main/linux-64::libffi-3.2.1-hd88cf55_4
  libgcc-ng          pkgs/main/linux-64::libgcc-ng-9.1.0-hdf63c60_0
  libgfortran-ng     pkgs/main/linux-64::libgfortran-ng-7.3.0-hdf63c60_0
  libstdcxx-ng       pkgs/main/linux-64::libstdcxx-ng-9.1.0-hdf63c60_0
  mkl                pkgs/main/linux-64::mkl-2019.4-243
  mkl-service        pkgs/main/linux-64::mkl-service-2.3.0-py37he904b0f_0
  mkl_fft            pkgs/main/linux-64::mkl_fft-1.0.15-py37ha843d7b_0
  mkl_random         pkgs/main/linux-64::mkl_random-1.1.0-py37hd6b4f25_0
  ncurses            pkgs/main/linux-64::ncurses-6.1-he6710b0_1
  numpy              pkgs/main/linux-64::numpy-1.17.3-py37hd14ec0e_0
  numpy-base         pkgs/main/linux-64::numpy-base-1.17.3-py37hde5b4d6_0
  openssl            pkgs/main/linux-64::openssl-1.1.1d-h7b6447c_3
  pip                pkgs/main/linux-64::pip-19.3.1-py37_0
  python             pkgs/main/linux-64::python-3.7.5-h0371630_0
  readline           pkgs/main/linux-64::readline-7.0-h7b6447c_5
  scikit-learn       pkgs/main/linux-64::scikit-learn-0.21.3-py37hd81dba3_0
  scipy              pkgs/main/linux-64::scipy-1.3.1-py37h7c811a0_0
  setuptools         pkgs/main/linux-64::setuptools-41.6.0-py37_0
  six                pkgs/main/linux-64::six-1.12.0-py37_0
  sqlite             pkgs/main/linux-64::sqlite-3.30.1-h7b6447c_0
  tk                 pkgs/main/linux-64::tk-8.6.8-hbc83047_0
  wheel              pkgs/main/linux-64::wheel-0.33.6-py37_0
  xz                 pkgs/main/linux-64::xz-5.2.4-h14c3975_4
  zlib               pkgs/main/linux-64::zlib-1.2.11-h7b6447c_3


Proceed ([y]/n)? 
Y

第2步:激活conda环境并测试scikit-learn

现在将Scikit-learn及它所有依赖项安装到新创建的conda环境中!安装完成后,我们看到指示如何激活和停用刚创建的新conda环境的输出,这与激活和停用使用venv模块创建的虚拟环境非常相似:


#
# To activate this environment, use
#
#     $ conda activate conda-scikit
#
# To deactivate an active environment, use
#
#     $ conda deactivate

继续并激活conda环境,以确保scikit-learn可用:


root@ubuntu:~# conda activate conda-scikit
(conda-scikit) root@ubuntu:~#

现在conda环境处于活动状态,跳入Python shell并访问该默认数据集:


Python 3.7.5 (default, Oct 25 2019, 15:51:11)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

接下来,粘贴以下代码段,然后按Enter键:


from sklearn import datasets
iris = datasets.load_iris()
digits = datasets.load_digits()
print(digits.data)

你应该在python shell中看到此输出:


[[ 0.  0.  5. ...  0.  0.  0.]
 [ 0.  0.  0. ... 10.  0.  0.]
 [ 0.  0.  0. ... 16.  9.  0.]
 ...
 [ 0.  0.  1. ...  6.  0.  0.]
 [ 0.  0.  2. ... 12.  0.  0.]
 [ 0.  0. 10. ... 12.  1.  0.]]


文章标签:learn  了解scikit  Anaconda  

正文

Copyright © 2011 HelpLib All rights reserved.    知识分享协议 京ICP备17041772号-2  |  如果智培  |  酷兔英语  |  帮酷