機器學習算法庫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 install numpy and scipy from their own official installers.

Wheel packages (.whl files) for scikit-learn from PyPI can be installed with the pip utility. 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 installers or from a Python distribution instead.

 

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,你可以執行如下的命令:

sudo apt-get install build-essential python-dev python-setuptools \
                     python-numpy python-scipy \
                     libatlas-dev libatlas3gf-base

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

sudo apt-get install build-essential python3-dev python3-setuptools \
                     python3-numpy python3-scipy \
                     libatlas-dev libatlas3gf-base

安裝matplotlib

sudo apt-get install python-matplotlib

3.2 在centos或者redhat下可以這樣安裝:

sudo yum -y install gcc gcc-c++ numpy python-devel scipy

3.3. 使用pip安裝scikit-learn

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

 




免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM