scikit-learn 机器学习算法库scikit-learn的安装

机器学习算法库scikit-learn的安装

scikit-learn 是一个python实现的免费开源的机器学习算法包,从字面意思可知,science 代表科学,kit代表工具箱,直接翻译过来就是用于机器学习的科学计算包。

安装scikit-learn有两种方式:

(1)安装官方发布的包。

(2)安装第三方开发工具,里边已经包含了scikit-learn。

对于(2),我推荐的是canopy,在mac和windows都比较好用。可以不用考虑安装python,numpy,scipy,因为canopy已经自自带了这些。

scikit-learn需要以下包或者工具:

Python (>= 2.6 or >= 3.3),

NumPy (>= 1.6.1),

SciPy (>= 0.9).

其实往往我们还需要matplotlib,这个可以非常方便的画图显示数据,可以有matlab一样的效果。

1. Windows下的安装

First you need to installnumpyandscipyfrom their own official installers.

Wheel packages (.whl files) for scikit-learn fromPyPIcan be installed with thepiputility. Open a console and type the following to install or upgrade scikit-learn to the latest stable release:

pip install -U scikit-learn

If there are no binary packages matching your Python version you might to try to install scikit-learn and its dependencies fromChristoph Gohlke Unofficial Windows installersor from aPython distributioninstead.

2. Mac下的安装

Scikit-learn and its dependencies are all available as wheel packages for OSX:

pip install -U numpy scipy scikit-learn

3. Linux下的安装

linux下没有提供像windows和Mac下那样方便的安装包,所以必须手工创建依赖库。

从源码安装需要scikit-learn运行依赖库、python开发头文件,c/c++编译器。

3.1 Under Debian-based operating systems, which include Ubuntu, if you have Python 2 you can install all these requirements by issuing:

如果是python2.6或者python2.7,你可以执行如下的命令:

sudoapt-getinstallbuild-essential python-dev python-setuptools \

python-numpy python-scipy \

libatlas-dev libatlas3gf-base

如果是python3.3或者python3.4,你可以执行如下的命令:

sudoapt-getinstallbuild-essential python3-dev python3-setuptools \

python3-numpy python3-scipy \

libatlas-dev libatlas3gf-base

安装matplotlib

sudoapt-getinstallpython-matplotlib

3.2 在centos或者redhad下可以这样安装:

sudoyum-yinstallgccgcc-c++ numpy python-devel scipy

3.3. 使用pip安装scikit-learn

pipinstall--user --install-option="--prefix="-U scikit-learn

你可能感兴趣的:(scikit-learn 机器学习算法库scikit-learn的安装)