您好,登錄后才能下訂單哦!
這篇文章主要講解了“Python算法庫的安裝過程”,文中的講解內容簡單清晰,易于學習與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學習“Python算法庫的安裝過程”吧!
Python算法庫包含以下幾個程序包,官方下載地址:
https://pypi.python.org/pypi
下載的算法庫要與安裝的Python版本一致,比如安裝的是Python3.7-64位版本,下載的算法庫要為cp37...win_amd64,否則安裝時會報錯。Python算法庫的安裝順序為:NumPy->SciPy->Matplotlib->Scikit-Learn。
NumPy:
array processing for numbers, strings, records, and objects.
NumPy是一個開源的Python科學計算庫。使用NumPy,就可以很自然地使用數組和矩陣。NumPy包含很多實用的數學函數,涵蓋線性代數運算、傅里葉變換和隨機數生成等功能。NumPy通常與SciPy和Matplotlib一起使用,這種組合廣泛用于替代MatLab(一個流行的技術計算平臺),Python作為MatLab的替代方案,現在被視為一種更加現代和完整的編程語言。
安裝:
C:\Program Files\Python37\Scripts>pip install d:\numpy-1.15.2-cp37-none-win_amd64.whl
Processing d:\numpy-1.15.2-cp37-none-win_amd64.whl
Installing collected packages: numpy
Successfully installed numpy-1.15.2
SciPy:
Scientific Library for Python.
SciPy是一個開源的Python科學計算庫,建立在Numpy之上。它增加的功能包括數值積分、最優化、統計和一些專用函數。SciPy函數庫在NumPy庫的基礎上增加了眾多的數學、科學以及工程計算中常用的庫函數。例如插值運算、線性代數、常微分方程數值求解、信號處理、圖像處理、稀疏矩陣等等。
安裝:
C:\Program Files\Python37\Scripts>pip install d:\scipy-1.1.0-cp37-none-win_amd64.whl
Processing d:\scipy-1.1.0-cp37-none-win_amd64.whl
Requirement already satisfied: numpy>=1.8.2 in c:\program files\python37\lib\site-packages (from scipy==1.1.0) (1.15.2)
Installing collected packages: scipy
Successfully installed scipy-1.1.0
Matplotlib:
Python plotting package.
Matplotlib是一個Python 2D繪圖庫,它可以在各種平臺上以各種硬拷貝格式和交互式環境生成具有出版品質的圖形。Matplotlib只需幾行代碼即可生成曲線圖、直方圖、曲餅圖、散點圖等。
安裝:
C:\Program Files\Python37\Scripts>pip install d:\matplotlib-3.0.0-cp37-cp37m-win_amd64.whl
Processing d:\matplotlib-3.0.0-cp37-cp37m-win_amd64.whl
Collecting kiwisolver>=1.0.1 (from matplotlib==3.0.0)
Downloading https://files.pythonhosted.org/packages/7c/be/7ae355b45699460e369ebf88d86058fca26827933974cc3f6b6b7800a324/kiwisolver-1.0.1-cp37-none-win_amd64.whl (57kB)
100% |████████████████████████████████| 61kB 55kB/s
Collecting python-dateutil>=2.1 (from matplotlib==3.0.0)
Downloading https://files.pythonhosted.org/packages/cf/f5/af2b09c957ace60dcfac112b669c45c8c97e32f94aa8b56da4c6d1682825/python_dateutil-2.7.3-py2.py3-none-any.whl (211kB)
100% |████████████████████████████████| 215kB 74kB/s
Collecting cycler>=0.10 (from matplotlib==3.0.0)
Downloading https://files.pythonhosted.org/packages/f7/d2/e07d3ebb2bd7af696440ce7e754c59dd546ffe1bbe732c8ab68b9c834e61/cycler-0.10.0-py2.py3-none-any.whl
Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 (from matplotlib==3.0.0)
Downloading https://files.pythonhosted.org/packages/2b/4a/f06b45ab9690d4c37641ec776f7ad691974f4cf6943a73267475b05cbfca/pyparsing-2.2.2-py2.py3-none-any.whl (57kB)
100% |████████████████████████████████| 61kB 131kB/s
Requirement already satisfied: numpy>=1.10.0 in c:\program files\python37\lib\site-packages (from matplotlib==3.0.0) (1.15.2)
Requirement already satisfied: setuptools in c:\program files\python37\lib\site-packages (from kiwisolver>=1.0.1->matplotlib==3.0.0) (39.0.1)
Collecting six>=1.5 (from python-dateutil>=2.1->matplotlib==3.0.0)
Downloading https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Installing collected packages: kiwisolver, six, python-dateutil, cycler, pyparsing, matplotlib
Successfully installed cycler-0.10.0 kiwisolver-1.0.1 matplotlib-3.0.0 pyparsing-2.2.2 python-dateutil-2.7.3 six-1.11.0
Scikit-Learn:
A set of python modules for machine learning and data mining.
scikit-learn(簡記sklearn)是用python實現的機器學習算法庫。sklearn可以實現數據預處理、分類、回歸、降維、模型選擇等常用的機器學習算法。sklearn是基于NumPy, SciPy, matplotlib的。
安裝:
C:\Program Files\Python37\Scripts>pip install d:\scikit_learn-0.20.0-cp37-cp37m-win_amd64.whl
Processing d:\scikit_learn-0.20.0-cp37-cp37m-win_amd64.whl
Requirement already satisfied: scipy>=0.13.3 in c:\program files\python37\lib\site-packages (from scikit-learn==0.20.0) (1.1.0)
Requirement already satisfied: numpy>=1.8.2 in c:\program files\python37\lib\site-packages (from scikit-learn==0.20.0) (1.15.2)
Installing collected packages: scikit-learn
Successfully installed scikit-learn-0.20.0
可以簡單測試一下算法庫安裝后的效果,代碼如下:
#導入NumPy庫 import numpy as np #導入Matplotlib庫 import matplotlib.pyplot as plt import math #定義序列端點和樣本數 x = np.linspace(-math.pi, math.pi, 100) #定義函數 y0 = x / x - 1 y1 = np.sin(x) y2 = np.cos(x) y3 = x**2 - 2 * x - 1 #繪制曲線 plt.plot(x, y0, color = 'black', linewidth = 0.5) plt.plot(x, y1, label = '$y=sin(x)$', color = 'red', linewidth = 0.5) plt.plot(x, y2, label = '$y=cos(x)$', color = 'green', linewidth = 0.5) plt.plot(x, y3, label = '$y=x^2-2x+1$', color = 'blue', linewidth = 0.5) #定義坐標 plt.xlabel('Time(s)') plt.ylabel('Volt') plt.xlim(-4, 4) plt.ylim(-2, 2) #標題和圖示 plt.title('PyPlot') plt.legend() #顯示繪圖 plt.show()
感謝各位的閱讀,以上就是“Python算法庫的安裝過程”的內容了,經過本文的學習后,相信大家對Python算法庫的安裝過程這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是億速云,小編將為大家推送更多相關知識點的文章,歡迎關注!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。