機器學(xué)習(xí)算法庫scikit-learn的安裝
scikit-learn 是一個python實現(xiàn)的免費開源的機器學(xué)習(xí)算法包,從字面意思可知,science 代表科學(xué)僵控,kit代表工具箱专钉,直接翻譯過來就是用于機器學(xué)習(xí)的科學(xué)計算包。
安裝scikit-learn有兩種方式:
(1)安裝官方發(fā)布的包闪水。
(2)安裝第三方開發(fā)工具糕非,里邊已經(jīng)包含了scikit-learn。
對于(2)球榆,我推薦的是canopy朽肥,在mac和windows都比較好用〕侄ぃ可以不用考慮安裝python衡招,numpy,scipy每强,因為canopy已經(jīng)自自帶了這些始腾。
scikit-learn需要以下包或者工具:
Python (>= 2.6 or >= 3.3),
NumPy (>= 1.6.1),
SciPy (>= 0.9).
其實往往我們還需要matplotlib,這個可以非常方便的畫圖顯示數(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)建依賴庫辨绊。
從源碼安裝需要scikit-learn運行依賴庫奶栖、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或者redhat下可以這樣安裝:
sudoyum-yinstallgccgcc-c++ numpy python-devel scipy
3.3. 使用pip安裝scikit-learn
pipinstall--user --install-option="--prefix="-U scikit-learn