機(jī)器學(xué)習(xí)算法庫(kù)scikit-learn的安裝
scikit-learn 是一個(gè)python實(shí)現(xiàn)的免費(fèi)開源的機(jī)器學(xué)習(xí)算法包景东,從字面意思可知,science 代表科學(xué)纱控,kit代表工具箱,直接翻譯過來就是用于機(jī)器學(xué)習(xí)的科學(xué)計(jì)算包。
安裝scikit-learn有兩種方式:
(1)安裝官方發(fā)布的包袜漩。
(2)安裝第三方開發(fā)工具,里邊已經(jīng)包含了scikit-learn湾碎。
對(duì)于(2)宙攻,我推薦的是canopy,在mac和windows都比較好用介褥∽颍可以不用考慮安裝python,numpy柔滔,scipy溢陪,因?yàn)閏anopy已經(jīng)自自帶了這些。
scikit-learn需要以下包或者工具:
Python (>= 2.6 or >= 3.3),
NumPy (>= 1.6.1),
SciPy (>= 0.9).
其實(shí)往往我們還需要matplotlib廊遍,這個(gè)可以非常方便的畫圖顯示數(shù)據(jù)嬉愧,可以有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下那樣方便的安裝包喉前,所以必須手工創(chuàng)建依賴庫(kù)没酣。
從源碼安裝需要scikit-learn運(yùn)行依賴庫(kù)、python開發(fā)頭文件卵迂,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,你可以執(zhí)行如下的命令:
sudoapt-getinstallbuild-essential python-dev python-setuptools \
python-numpy python-scipy \
libatlas-dev libatlas3gf-base
如果是python3.3或者python3.4见咒,你可以執(zhí)行如下的命令:
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