为了简化操作,我们可以先下一个pip:https://pypi.python.org/pypi/pip#downloads,别忘了把pip所在的目录加入环境变量。
(先打开Python安装目录下的Scripts文件夹看看,可能在安装Python时就已经默认安装了)
之后的操作就很简单了,首先安装scikit_learn,打开cmd执行下面的命令:
pip install -U scikit-learn@See http://scikit-learn.org/stable/install.html
接着安装配套的Scipy全家桶:
pip install --user numpy scipy matplotlib ipython jupyter pandas sympy nose@See https://www.scipy.org/install.html
Scipy全家桶的清单大致如下:
MarkupSafe-1.0 Send2Trash-1.5.0 backports-abc-0.5 backports.functools-lru-cache-1.5 backports.shutil-get-terminal-size-1.0.0 backports.shutil-which-3.5.1 bleach-2.1.3 colorama-0.3.9 configparser-3.5.0 cycler-0.10.0 decorator-4.2.1 entrypoints-0.2.3 enum34-1.1.6 functools32-3.2.3.post2 futures-3.2.0 html5lib-1.0.1 ipykernel-4.8.2 ipython-5.5.0 ipython-genutils-0.2.0 ipywidgets-7.1.2 jinja2-2.10 jsonschema-2.6.0 jupyter-1.0.0 jupyter-client-5.2.3 jupyter-console-5.2.0 jupyter-core-4.4.0 kiwisolver-1.0.1 matplotlib-2.2.0 mistune-0.8.3 mpmath-1.0.0 nbconvert-5.3.1 nbformat-4.4.0 nose-1.3.7 notebook-5.4.0 numpy-1.14.2 pandas-0.22.0 pandocfilters-1.4.2 pathlib2-2.3.0 pickleshare-0.7.4 prompt-toolkit-1.0.15 pygments-2.2.0 pyparsing-2.2.0 python-dateutil-2.7.0 pytz-2018.3 pywinpty-0.5.1 pyzmq-17.0.0 qtconsole-4.3.1 scandir-1.7 simplegeneric-0.8.1 singledispatch-3.4.0.3 six-1.11.0 sympy-1.1.1 terminado-0.8.1 testpath-0.3.1 tornado-5.0 traitlets-4.3.2 wcwidth-0.1.7 webencodings-0.5.1 widgetsnbextension-3.1.4 win-unicode-console-0.5
from sklearn import datasets from sklearn.model_selection import cross_val_predict from sklearn import linear_model import matplotlib.pyplot as plt lr = linear_model.LinearRegression() boston = datasets.load_boston() y = boston.target # cross_val_predict returns an array of the same size as `y` where each entry # is a prediction obtained by cross validation: predicted = cross_val_predict(lr, boston.data, y, cv=10) fig, ax = plt.subplots() ax.scatter(y, predicted, edgecolors=(0, 0, 0)) ax.plot([y.min(), y.max()], [y.min(), y.max()], 'k--', lw=4) ax.set_xlabel('Measured') ax.set_ylabel('Predicted') plt.show()结果如下:
----------------------------------------------
报错:# requires numpy+mkl
执行命令:
pip uninstall numpy把这个旧版本的卸载掉之后,从 https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy下载一个对应位数和Python版本的numpy+mkl包:
把下载的包找个地方放一下,执行命令:
pip install $你的包的路径/包名.whl*我这里有一个备份的python 2.7- 32位包: https://download.csdn.net/download/shenpibaipao/10288435
python 2.7- 64位包: https://download.csdn.net/download/shenpibaipao/10394701
---------------------------
>一些pip命令
查看已安装的模块:
pip list
安装模块:
pip install 包名卸载模块:
pip uninstall 包名
升级模块:(拉取库中的最新版本)
pip install --upgrade 包名