安装 sklearn 1. 安装 numpy ?scipy ?matplot
$ pip3 install numpy scipy matplotlib -i https://pypi.tuna.tsinghua.edu.cn/simple
2. 安装 sklearn
$ pip3 install scikit-learn -i https://pypi.tuna.tsinghua.edu.cn/simple
只为当前用户安装:
?$ pip3 install --user ?scikit-learn -i https://pypi.tuna.tsinghua.edu.cn/simple
? ?安装ipython
$ sudo apt install ipython3
试一下 sklearn加载数据:
$ ipython3
In [1]: from sklearn import *
In [2]: datasets
Out[2]: <module 'sklearn.datasets' from '/home/ethan/.virtualenvs/test3/lib/python3.5/site-packages/sklearn/datasets/__init__.py'>
In [9]: iris = datasets.load_iris()
In [10]: iris.data
Out[10]:
array([[5.1, 3.5, 1.4, 0.2],
。。。
In [11]: iris.target
In [12]: iris.DESCR
In [13]: iris.feature_names
Out[13]:
['sepal length (cm)',
'sepal width (cm)',
'petal length (cm)',
'petal width (cm)']
In [14]: iris.target
Out[14]:
array([0, 0, 0, 0, 0,
? ?---------------------------------------------------------------------------------------------- ?显示信息: ? ?Downloading https://pypi.tuna.tsinghua.edu.cn/packages/c1/1a/c7557d40fc0f94aa589fed98196dac67b030fda63e1b3ea2f269351cc409/kiwisolver-1.4.2-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl (1.2 MB) ? ? ?|████████████████████████████████| 1.2 MB 460 kB/s Installing collected packages: numpy, scipy, cycler, pyparsing, packaging, fonttools, kiwisolver, matplotlib ? WARNING: The scripts f2py, f2py3 and f2py3.8 are installed in '/home/opencl/.local/bin' which is not on PATH. ? Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. ? WARNING: The scripts fonttools, pyftmerge, pyftsubset and ttx are installed in '/home/opencl/.local/bin' which is not on PATH. ? Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. Successfully installed cycler-0.11.0 fonttools-4.33.3 kiwisolver-1.4.2 matplotlib-3.5.2 numpy-1.22.3 packaging-21.3 pyparsing-3.0.8 scipy-1.8.0 opencl@opencl-PC:~/ex/scikit-learn$
----------------------------------------------------------------------------------------------
numpy 学习网站: https://www.runoob.com/numpy/numpy-install.html
|